mongoengine
mongoengine copied to clipboard
Upsert does not update SequenceField
Is this intended behavior? I ran into a bug where when I called update_one withupsert=True, a sequencefield was not created for the object on creation.
Same here. SequenceField is left empty on update_one(upsert=True, **data) or upsert_one(). Not sure if it's intended.
Example code:
class Example(Document):
meta = {"collection": "examples", "db_alias": "default"}
example_id = SequenceField()
title = Stringfield()
Example.objects.upsert_one(title="lorem ipsum")
A workaround is to pass set_on_insert__example_id=Example.example_id.generate() to the upsert_one() method. But it increments the counter, even in case of an update.