Skip to content

Commit

Permalink
Fixed #25939 -- Removed redundant transaction in QuerySet.update_or_c…
Browse files Browse the repository at this point in the history
…reate().

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().
  • Loading branch information
bart0sh authored and timgraham committed Dec 15, 2015
1 parent 5146e2c commit 423b3af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions django/db/models/query.py
Expand Up @@ -484,9 +484,7 @@ def update_or_create(self, defaults=None, **kwargs):
return obj, created
for k, v in six.iteritems(defaults):
setattr(obj, k, v)

with transaction.atomic(using=self.db, savepoint=False):
obj.save(using=self.db)
obj.save(using=self.db)
return obj, False

def _create_object_from_params(self, lookup, params):
Expand Down
4 changes: 4 additions & 0 deletions docs/releases/1.10.txt
Expand Up @@ -363,6 +363,10 @@ Miscellaneous
:class:`~django.http.HttpResponse` are now closed immediately instead of when
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:

Features deprecated in 1.10
Expand Down

0 comments on commit 423b3af

Please sign in to comment.