From 17fc9d188609f5ce9f65ead57ca3bb10a93d878c Mon Sep 17 00:00:00 2001 From: Dmitry Voronenkov Date: Thu, 13 Jun 2019 19:58:44 +0300 Subject: [PATCH] Fix a big issue when determine if there is a new document or we need to update. With this issue all fields were update always (not only modified fields) --- mongoengine/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/document.py b/mongoengine/document.py index 341a41ba..c338263d 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -366,7 +366,7 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): if write_concern is None: write_concern = {} - doc_id = self.to_mongo(fields=['id']) + doc_id = self.to_mongo(fields=[self._meta['id_field']]) created = ('_id' not in doc_id or self._created or force_insert) signals.pre_save_post_validation.send(self.__class__, document=self,