mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

adding upsert option to save

Open voglster opened this issue 3 years ago • 6 comments

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.

voglster avatar Jun 17 '21 01:06 voglster

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?

voglster avatar Aug 28 '21 21:08 voglster

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?

voglster avatar Oct 23 '21 17:10 voglster

Thought i would check in again on this... any response?

voglster avatar Dec 09 '21 16:12 voglster

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?

voglster avatar Feb 24 '22 21:02 voglster

just remembered this PR, thought i would check in... Bumping it... bueller?

voglster avatar Sep 26 '22 16:09 voglster