-
Notifications
You must be signed in to change notification settings - Fork 427
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
bug: updating an item without getting it first resets it's version to 1 #1247
Comments
This was referenced Jul 24, 2024
You shouldn't need to run a Example: dynamodb lets you do this:
|
bpsoos
changed the title
updating an item without getting it first resets it's version to 1
bug: updating an item without getting it first resets it's version to 1
Aug 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Issue
Given a model with a version attribute:
a simple update on the model without getting it first resets it's version to 1:
manual version update also fails with "Two document paths overlap with each other" error as the
update
method automatically adds aSET
operation for the version and they conflict:The same issues apply to updates in transactions.
See the integration tests in the linked pull request for runnable versions of these examples.
Root cause
The root cause seems to be in Model._handle_version_attribute, which automatically tries to increment the models version and sets it to 1 if
getattr(self, self._version_attribute_name)
returnsNone
.Solution proposal
I propose to add an
increment_version
flag to the relevant Model methods, similar toadd_version_condition
.For example:
The text was updated successfully, but these errors were encountered: