mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #22343 -- Disallowed select_for_update in autocommit mode
The ticket was originally about two failing tests, which are fixed by putting their queries in transactions. Thanks Tim Graham for the report, Aymeric Augustin for the fix, and Simon Charette, Tim Graham & Loïc Bistuer for review.
This commit is contained in:
parent
071c933775
commit
f095356ba2
6 changed files with 94 additions and 4 deletions
|
@ -5,7 +5,33 @@ Django 1.6.3 release notes
|
|||
*Under development*
|
||||
|
||||
This is Django 1.6.3, a bugfix release for Django 1.6. Django 1.6.3 fixes
|
||||
several bugs in 1.6.2:
|
||||
several bugs in 1.6.2 and makes one backwards-incompatible change:
|
||||
|
||||
``select_for_update()`` requires a transaction
|
||||
==============================================
|
||||
|
||||
Historically, queries that use
|
||||
:meth:`~django.db.models.query.QuerySet.select_for_update()` could be
|
||||
executed in autocommit mode, outside of a transaction. Before Django
|
||||
1.6, Django's automatic transactions mode allowed this to be used to
|
||||
lock records until the next write operation. Django 1.6 introduced
|
||||
database-level autocommit; since then, execution in such a context
|
||||
voids the effect of ``select_for_update()``. It is, therefore, assumed
|
||||
now to be an error, and raises an exception.
|
||||
|
||||
This change may cause test failures if you use ``select_for_update()``
|
||||
in a test class which is a subclass of
|
||||
:class:`~django.test.TransactionTestCase` rather than
|
||||
:class:`~django.test.TestCase`.
|
||||
|
||||
This change was made because such errors can be caused by including an
|
||||
app which expects global transactions (e.g. :setting:`ATOMIC_REQUESTS
|
||||
<DATABASE-ATOMIC_REQUESTS>` set to True), or Django's old autocommit
|
||||
behavior, in a project which runs without them; and further, such
|
||||
errors may manifest as data-corruption bugs.
|
||||
|
||||
Other bugfixes and changes
|
||||
==========================
|
||||
|
||||
* Content retrieved from the GeoIP library is now properly decoded from its
|
||||
default ``iso-8859-1`` encoding
|
||||
|
|
|
@ -1086,6 +1086,31 @@ Note also that the admin login form has been updated to not contain the
|
|||
``this_is_the_login_form`` field (now unused) and the ``ValidationError`` code
|
||||
has been set to the more regular ``invalid_login`` key.
|
||||
|
||||
``select_for_update()`` requires a transaction
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Historically, queries that use
|
||||
:meth:`~django.db.models.query.QuerySet.select_for_update()` could be
|
||||
executed in autocommit mode, outside of a transaction. Before Django
|
||||
1.6, Django's automatic transactions mode allowed this to be used to
|
||||
lock records until the next write operation. Django 1.6 introduced
|
||||
database-level autocommit; since then, execution in such a context
|
||||
voids the effect of ``select_for_update()``. It is, therefore, assumed
|
||||
now to be an error, and raises an exception.
|
||||
|
||||
This change may cause test failures if you use ``select_for_update()``
|
||||
in a test class which is a subclass of
|
||||
:class:`~django.test.TransactionTestCase` rather than
|
||||
:class:`~django.test.TestCase`.
|
||||
|
||||
This change was made because such errors can be caused by including an
|
||||
app which expects global transactions (e.g. :setting:`ATOMIC_REQUESTS
|
||||
<DATABASE-ATOMIC_REQUESTS>` set to True), or Django's old autocommit
|
||||
behavior, in a project which runs without them; and further, such
|
||||
errors may manifest as data-corruption bugs.
|
||||
|
||||
This was also fixed in Django 1.6.3.
|
||||
|
||||
Miscellaneous
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue