From 3a9a4570efc933a50efec27bdd06af11877eeac6 Mon Sep 17 00:00:00 2001 From: Shai Berger Date: Sun, 30 Mar 2014 20:03:35 +0300 Subject: [1.7.x] Fixed #22343 -- Disallowed select_for_update in autocommit mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- docs/ref/models/querysets.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docs/ref/models') diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index f10f66425a..dce93e7096 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -1378,9 +1378,19 @@ do not support ``nowait``, such as MySQL, will cause a :exc:`~django.db.DatabaseError` to be raised. This is in order to prevent code unexpectedly blocking. +Executing a queryset with ``select_for_update`` in autocommit mode is +an error because the rows are then not locked. If allowed, this would +facilitate data corruption, and could easily be caused by calling, +outside of any transaction, code that expects to be run in one. + Using ``select_for_update`` on backends which do not support ``SELECT ... FOR UPDATE`` (such as SQLite) will have no effect. +.. versionchanged:: 1.6.3 + + It is now an error to execute a query with ``select_for_update()`` in + autocommit mode. With earlier releases in the 1.6 series it was a no-op. + raw ~~~ -- cgit v1.3