hmarr/mongoengine — Issue #387: update() semantics confusing
Author: thomasst
Created: 2011-12-07 23:37:29+00:00
State: open

When specifying keyword args in update(), mongoengine should assume by default that we'd like to set those properties. Considering the following statement:

models.Entry.objects.filter(pk=my_doc).update_one(name='Hello')

After executing that line, the document with pk=my_doc will be removed from Mongo (re-running the filter statement will result in an empty queryset). This is very unintuitive, therefore I propose to have mongoengine automatically transform it into a "set" comand behind the scenes:

models.Entry.objects.filter(pk=my_doc).update_one(set__name='Hello')

Also, running update() on a similar queryset returns a "'OperationError: Update failed (multi update only works with $ operators)'", which is similarly confusing.