Closed Luc1412 closed 1 year ago
This looks wrong when you expecting from save_changes()
creating new documents.
But if document existed and you trying to save changes (e.g. some race condition deleted doc) this have to happen.
In my case I got a custom fetch document that either finds the document by _id or creates a new document if not found.
To save changes, I only use save_changes() so I don't know weather the document is fetched from db or not.
So I subclassed Document to overwrite save_changes() to insert the doc if it was just created.
Currently save() inserts the document too, if newly created, so it might make sense to implement that for save_changes() too. Otherwise at least something should happen when saving_changes on a non existent doc e.g. an exception should be raised.
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.
Describe the bug In 1.11.9 state was changed and always defaults being not None, instead it got a dict with the default values. This causes
check_if_state_saved
to never throw an error.save_changes
on a new created document that isn't saved in the database silently does nothing.To Reproduce
Expected behavior
StateNotSaved("No state was saved")
Additional context https://github.com/roman-right/beanie/compare/1.11.8...1.11.9 https://canary.discord.com/channels/822196934973456394/822196935435747332/1042243293662158970