From 91547772e04e456f45c7ef86e1f76d087821c89d Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 7 Oct 2013 10:47:50 +0200 Subject: [PATCH] Fixed #21235 -- Disabled savepoints for old versions of SQLite. Thanks Ramiro for the report. --- django/db/backends/sqlite3/base.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index ac2376a819..ef214234e9 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -393,12 +393,16 @@ class DatabaseWrapper(BaseDatabaseWrapper): BaseDatabaseWrapper.close(self) def _savepoint_allowed(self): + # Two conditions are required here: + # - A sufficiently recent version of SQLite to support savepoints, + # - Being in a transaction, which can only happen inside 'atomic'. + # When 'isolation_level' is not None, sqlite3 commits before each # savepoint; it's a bug. When it is None, savepoints don't make sense - # because autocommit is enabled. The only exception is inside atomic - # blocks. To work around that bug, on SQLite, atomic starts a + # because autocommit is enabled. The only exception is inside 'atomic' + # blocks. To work around that bug, on SQLite, 'atomic' starts a # transaction explicitly rather than simply disable autocommit. - return self.in_atomic_block + return self.features.uses_savepoints and self.in_atomic_block def _set_autocommit(self, autocommit): if autocommit: