Closed miteshjadia closed 1 year ago
Hey, Thank you for the issue. It looks like a bug. I'll pick this up soon
This issue is stale because it has been open 30 days with no activity.
This issue was closed because it has been stalled for 14 days with no activity.
When the init_beanie of a model is done using 'use_state_management' and 'use_revision' below sequence of operation does not work.
1) find_one 2) make some change in object and call save_changes() 3) make some more change in the same object and call save_changes() <<-- (This throws exception for revision got changes.)
Attached python code to trigger issue. test_beanie.py.txt
Output of attached program.
Found the product from DB id=ObjectId('62a6e577cba0666769ac7175') revision_id=UUID('d83df2b4-8c37-42eb-b4b7-20ccd1ac3207') name='test_product' description='some description' price=6.249999999999999
Save changes first attempt success id=ObjectId('62a6e577cba0666769ac7175') revision_id=UUID('5e3561e8-1d96-4ff0-bb0d-87db3c6517cb') name='test_product' description='some description' price=6.349999999999999
Save changes seconds attempt failed Traceback (most recent call last): File "/app/test_beanie.py", line 83, in example await product.save_changes() File "/usr/local/lib/python3.9/site-packages/beanie/odm/utils/state.py", line 29, in async_wrapper return await f(self, *args, kwargs) File "/usr/local/lib/python3.9/site-packages/beanie/odm/actions.py", line 212, in wrapper result = await f(self, *args, skip_actions=skip_actions, *kwargs) File "/usr/local/lib/python3.9/site-packages/beanie/odm/utils/self_validation.py", line 12, in wrapper return await f(self, args, kwargs) File "/usr/local/lib/python3.9/site-packages/beanie/odm/documents.py", line 429, in save_changes await self.set( File "/usr/local/lib/python3.9/site-packages/beanie/odm/utils/state.py", line 39, in wrapper result = await f(self, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/beanie/odm/documents.py", line 492, in update raise RevisionIdWasChanged beanie.exceptions.RevisionIdWasChanged