mirror of https://github.com/django/django.git
Simplified QuerySet.update_or_create() a bit.
This commit is contained in:
parent
7bba231b67
commit
1081d24f99
|
@ -970,10 +970,10 @@ class QuerySet(AltersData):
|
|||
Return a tuple (object, created), where created is a boolean
|
||||
specifying whether an object was created.
|
||||
"""
|
||||
update_defaults = defaults or {}
|
||||
if create_defaults is None:
|
||||
update_defaults = create_defaults = defaults or {}
|
||||
else:
|
||||
update_defaults = defaults or {}
|
||||
create_defaults = update_defaults
|
||||
|
||||
self._for_write = True
|
||||
with transaction.atomic(using=self.db):
|
||||
# Lock the row so that a concurrent update is blocked until
|
||||
|
|
Loading…
Reference in New Issue