boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

Deserialize Numbers as-is. Truncate insignificant Decimal digits in serialization to fit precision.

Open JustinTArthur opened this issue 4 years ago • 3 comments

DynamoDB doesn't persist Number format details like insignificant digits so enforcing that persistence in the Decimal context unnecessarily breaks valid marshaling scenarios such as deserializing the valid DynamoDB value {"N": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"} (1E+100).

The current decimal context includes a Rounded trap, which is actually a truncation trap that currently prevents us from collapsing insignificant digits. We're still protected from accidentally losing information as long as we continue to include the Inexact trap.

Fixes boto/boto3#2500.

JustinTArthur avatar Jun 30 '21 07:06 JustinTArthur

Thanks, @nyh. I agree, and by not performing the same checks on deserialization, we improve performance. I've adjusted the pull request accordingly. I still remove the Rounded check to fix the same scenario during serialization where we still want to check against Dynamo's decimal rules.

JustinTArthur avatar Jul 02 '21 04:07 JustinTArthur

@JustinTArthur Looks like this has ben hanging out for a bit over a year, any issue with merging?

alukach avatar Sep 07 '22 19:09 alukach

@JustinTArthur Looks like this has ben hanging out for a bit over a year, any issue with merging?

The only issue with merging is that no one has merged it yet :) I'll happily resolve the conflicts if Amazon hints they are actually ready for the fix.

In the meantime, you can use ddbcereal with the low-level client of boto3, botocore, aioboto3, or aiobotocore.

JustinTArthur avatar Sep 10 '22 17:09 JustinTArthur

Hi, thanks for this pull request and for your patience. We're going to close this pull request at this time, as this is a breaking change. I'll be leaving the bug report open for tracking purposes, and marking it as "needs-major-version" to be considered. Thank you again for contributing.

RyanFitzSimmonsAK avatar Mar 28 '24 20:03 RyanFitzSimmonsAK

@RyanFitzSimmonsAK in what way is it a breaking change? Right now, trying to deserialize and serialize valid DynamoDB Numbers can throw an unexpected exception and this PR fixes that. There should be no other changes to behavior or user expectations as far as I know and if you think there are, let's work through them.

JustinTArthur avatar Mar 28 '24 20:03 JustinTArthur