Merge pull request #1946 from erdenezul/refactor_write_concern

Refactor write_concern #1945
This commit is contained in:
erdenezul 2018-11-09 09:30:20 +08:00 committed by GitHub
commit 28a312accf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,7 +297,7 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)):
return True return True
def save(self, force_insert=False, validate=True, clean=True, def save(self, force_insert=False, validate=True, clean=True,
write_concern=None, cascade=None, cascade_kwargs=None, write_concern={'w': 1}, cascade=None, cascade_kwargs=None,
_refs=None, save_condition=None, signal_kwargs=None, **kwargs): _refs=None, save_condition=None, signal_kwargs=None, **kwargs):
"""Save the :class:`~mongoengine.Document` to the database. If the """Save the :class:`~mongoengine.Document` to the database. If the
document already exists, it will be updated, otherwise it will be document already exists, it will be updated, otherwise it will be
@ -359,9 +359,6 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)):
if validate: if validate:
self.validate(clean=clean) self.validate(clean=clean)
if write_concern is None:
write_concern = {'w': 1}
doc = self.to_mongo() doc = self.to_mongo()
created = ('_id' not in doc or self._created or force_insert) created = ('_id' not in doc or self._created or force_insert)