1
0
mirror of https://github.com/django/django.git synced 2025-03-13 10:50:55 +00:00

Simplified QuerySet.update_or_create() a bit.

This commit is contained in:
Muzaffer Cikay 2023-08-25 07:39:35 +03:00 committed by GitHub
parent 7bba231b67
commit 1081d24f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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