From 164e2b2678a7d88deb00aa353662e69ad7a6100c Mon Sep 17 00:00:00 2001 From: srossiter Date: Tue, 24 Nov 2015 12:53:09 +0000 Subject: [PATCH] Docstring change and rename variable to avoid clash with kwargs --- mongoengine/queryset/base.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mongoengine/queryset/base.py b/mongoengine/queryset/base.py index 5c44db9c..ce4174b9 100644 --- a/mongoengine/queryset/base.py +++ b/mongoengine/queryset/base.py @@ -473,8 +473,7 @@ class BaseQuerySet(object): def upsert_one(self, write_concern=None, **update): - """Perform an atomic upsert on the fields of the first document - matched by the query. + """Overwrite or add the first document matched by the query. :param write_concern: Extra keyword arguments are passed down which will be used as options for the resultant @@ -486,16 +485,16 @@ class BaseQuerySet(object): :returns the new or overwritten document - .. versionadded:: 10.0.2 + .. versionadded:: 0.10.2 """ - update = self.update(multi=False, upsert=True, write_concern=write_concern, + atomic_update = self.update(multi=False, upsert=True, write_concern=write_concern, full_result=True,**update) - if update['updatedExisting']: + if atomic_update['updatedExisting']: document = self.get() else: - document = self._document.objects.with_id(update['upserted']) + document = self._document.objects.with_id(atomic_update['upserted']) return document def update_one(self, upsert=False, write_concern=None, **update):