Fix Document.modify fail on sharded collection #1569

This commit is contained in:
Erdenezul 2017-08-30 12:04:04 +08:00
parent 0325a62f18
commit 1eae97731f

View File

@ -280,6 +280,9 @@ class Document(BaseDocument):
elif query[id_field] != self.pk:
raise InvalidQueryError('Invalid document modify query: it must modify only this document.')
# Need to add shard key to query, or you get an error
query.update(self._object_key)
updated = self._qs(**query).modify(new=True, **update)
if updated is None:
return False