mongoengine
mongoengine copied to clipboard
adding upsert option to save
I believe this addresses #564 without breaking backwards compatibility. Allowing you to explicitly choose not to upsert so you don't create bad documents in your database.
This may not be the correct solve long term as save as it is can literally break your database if you delete the backing object between when you loaded this one but it does maintain backwards compatibility in case someone is using that "feature".
Includes tests as well, my first pull request here so let me know if I need to do anything else.
Thanks for your feedback @bagerard.
I am not sure of a clean way to handle the 3 states of upsert (explicitly set True/False vs implicitly set via the save_condition argument) Any help/ideas from you would be appreciated there. But the default is not necessarily True.
I did add a new commit adding the guard against seting upsert=True and a save_condition along with the relevant test but am unsure if I am raising the correct exception. Perhaps OperationError instead?
I made the small changes raising exceptions but got no response on the True vs None because of the three states a month ago. Any updates/thoughts?
Thought i would check in again on this... any response?
It has been ~3 months and closing in on a year since my original pull request,
Thought I would check in again on this... any response?
just remembered this PR, thought i would check in... Bumping it... bueller?