From 64b63e9d52924f60af2a938b769fb12631494d3f Mon Sep 17 00:00:00 2001 From: George Pearson Date: Fri, 24 May 2019 12:49:04 +0100 Subject: [PATCH] Use update_one instead of deprecated update #1899 --- mongoengine/document.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mongoengine/document.py b/mongoengine/document.py index 5ccedbfa..03b659e3 100644 --- a/mongoengine/document.py +++ b/mongoengine/document.py @@ -502,8 +502,12 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): update_doc = self._get_update_doc() if update_doc: upsert = save_condition is None - last_error = collection.update(select_dict, update_doc, - upsert=upsert, **write_concern) + with set_write_concern(collection, write_concern) as wc_collection: + last_error = wc_collection.update_one( + select_dict, + update_doc, + upsert=upsert + ).raw_result if not upsert and last_error['n'] == 0: raise SaveConditionError('Race condition preventing' ' document update detected')