fix(data-classes): keep the value of large DynamoDB numbers - #8513
leandrodamascena merged 3 commits into
Conversation
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8513 +/- ##
========================================
Coverage 96.92% 96.92%
========================================
Files 317 317
Lines 15910 15911 +1
Branches 1398 1398
========================================
+ Hits 15421 15422 +1
Misses 353 353
Partials 136 136 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
Thanks for the fix, @chiruu12! I pushed a small follow-up after testing some edge cases. Normalization now raises |
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |



Issue number: closes #8512
Summary
Changes
_deserialize_nused to count characters and slice the string when a number was longer than 38. The minus sign and the decimal point were counted as digits, and removing trailing zeros by slicing changed the magnitude.It now parses with
Decimal(value). When the coefficient has more than 38 digits, it is normalized with a 38-digit context, which moves trailing zeros into the exponent.DYNAMODB_CONTEXT.create_decimalthen accepts it without raisingRounded(#4845) and the value is unchanged. Numbers with 38 digits or fewer go through as before.Tests:
tests/unit/shared/test_dynamodb_deserializer.pycovering a negative 38-digit number, a 38-digit decimal, the value from DynamoDBRecord throws decimal.Rounded for large numbers (over 38 digits) #4845 and a 38-digit number times 1000. All four fail on develop.test_dynamodb_stream_record_deserialization_large_intasserted that a 47-digit number came back as a 38-digit one. Its expected value is now the original number.test_dynamodb_stream_record_deserialization_large_int_without_trailing_zerosuses a value with more than 38 significant digits, which DynamoDB can't store. It now expects the number rounded to 38 digits at the same magnitude, instead of the first 38 characters.User experience
Before:
After:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.