-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for versioned optimistic locking a la DynamoDBMapper #664
Conversation
@garrettheel @jpinner-lyft This is a pretty well-done contribution! We have been traditionally rejecting new features that don't map somehow to core DynamoDB features, instead pointing authors at pynamodb-attributes. However, this feature wouldn't be possible through attributes alone, since it modifies What do you think? |
I'm supportive of putting this into the core given that this is such a common pattern. I took a quick first pass and it mostly looks good! I'll give it more of a look over the next few days. Would love to see some docs with usage examples (especially exceptions) here too. |
Ahh, I somehow missed that this maps to a DynamoDBMapper feature. |
(On a side note, I'd love if we could add something like blinker signals so that such behaviors could be implemented by plugins.) |
The more recent update modifies the behavior of save to update the local object i.e. can be called multiple times without needing to refresh. I implemented this in Model.save since https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html#DDB-PutItem-request-ReturnValues only supports ReturnValues of NONE or ALL_OLD. I'll also update this later tonight for Transactions. |
I was thinking I would wait to add docs and examples until people are happy with what I've implemented, so that I only have do it once. For exceptions it doesn't look like I can differentiate whether a condition check failed because of the version attribute or some other conditional expression, so there won't be anything interesting there. I'll be sure to add examples with exceptions when I get there though. |
2ea2617
to
e43a3a6
Compare
Rebased and squashed to a single commit. |
2f39459
to
08c7647
Compare
The squash-and-force-push workflow used to make it hard to track changes, but I just realized GitHub allows now to see the diffs between the force-push and the commit it replaced. |
Still error-prone though. :D |
@ikonst @garrettheel Any idea when you'll have time for another pass? |
@ezmuller docs look good, thanks for writing those! I think this is pretty much ready to go, just a couple of final small comments |
Np feature wouldn't be all that useful undocumented. Thanks for taking the time to go through all the revisions @garrettheel @ikonst ! |
ca5d140
to
d241ef0
Compare
Squashed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the effort here!
Adds a new nullable version attribute type which initializes at 1 and increments on save/update for optimistic locking.