1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

[1.7.x] 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.

Backport of b990df1d63 from master
This commit is contained in:
Shai Berger
2014-03-30 20:03:35 +03:00
parent f6f188ffc7
commit 3a9a4570ef
6 changed files with 98 additions and 2 deletions

View File

@@ -722,7 +722,10 @@ Select for update
If you were relying on "automatic transactions" to provide locking between
:meth:`~django.db.models.query.QuerySet.select_for_update` and a subsequent
write operation — an extremely fragile design, but nonetheless possible — you
must wrap the relevant code in :func:`atomic`.
must wrap the relevant code in :func:`atomic`. Since Django 1.6.3, executing
a query with :meth:`~django.db.models.query.QuerySet.select_for_update` in
autocommit mode will raise a
:exc:`~django.db.transaction.TransactionManagementError`.
Using a high isolation level
~~~~~~~~~~~~~~~~~~~~~~~~~~~~