Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add ability to use Decimal for DynamoDB numeric types #1183
The gist of this change is to refactor the
This interface is then plumbed into Layer2 and can be passed in
I implemented two types of Dynamizers:
I made the default dynamizer the LossyFloatDynamizer which will
If a user wants to use decimals, they can either pass in the
dynamodb = boto.connect_dynamodb(dynamizer=Dynamizer)
or use the
dynamodb = boto.connect_dynamodb() dynamodb.use_decimals()
If a user wants to customize this process, they can subclass
class UnicodeDynamizer(Dynamizer): def decode_s(self, attr): return unicode(attr) dynamodb = boto.connect_dynamodb(dynamizer=UnicodeDynamizer)
I've added unittests/integration tests for the new functionality.
If this approach looks reasonable I can update the user docs, API docstrings,
Thanks for working on this; this issue has been gnawing at me for awhile now. Since your implementation matches my original proposal from 4 months ago, of course I'm in favor of it. :-)
I have only a couple comments on the code:
Great feedback, thanks for reviewing the PR.
This was referenced
Jan 7, 2013
Is there a reason that Decimal is being used for both whole and fractional numbers? As opposed to using int for integers and only replacing floats with Decimal?
Currently, when pulling items from DynamoDB using Decimals entirely, it's not possible for me to determine which fields/columns are integers and which ones are fractional.