Kaydet (Commit) 423b3afc authored tarafından Ed Bartosh's avatar Ed Bartosh Kaydeden (comit) Tim Graham

Fixed #25939 -- Removed redundant transaction in QuerySet.update_or_create().

There is no need to wrap the save() call in transaction.atomic() as
it's already done down the call stack in Model.save_base().
üst 5146e2cf
...@@ -484,9 +484,7 @@ class QuerySet(object): ...@@ -484,9 +484,7 @@ class QuerySet(object):
return obj, created return obj, created
for k, v in six.iteritems(defaults): for k, v in six.iteritems(defaults):
setattr(obj, k, v) setattr(obj, k, v)
obj.save(using=self.db)
with transaction.atomic(using=self.db, savepoint=False):
obj.save(using=self.db)
return obj, False return obj, False
def _create_object_from_params(self, lookup, params): def _create_object_from_params(self, lookup, params):
......
...@@ -363,6 +363,10 @@ Miscellaneous ...@@ -363,6 +363,10 @@ Miscellaneous
:class:`~django.http.HttpResponse` are now closed immediately instead of when :class:`~django.http.HttpResponse` are now closed immediately instead of when
the WSGI server calls ``close()`` on the response. the WSGI server calls ``close()`` on the response.
* A redundant ``transaction.atomic()`` call in ``QuerySet.update_or_create()``
is removed. This may affect query counts tested by
``TransactionTestCase.assertNumQueries()``.
.. _deprecated-features-1.10: .. _deprecated-features-1.10:
Features deprecated in 1.10 Features deprecated in 1.10
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment