diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-10-07 10:47:50 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-10-07 10:49:28 +0200 |
| commit | b42f0665a8cc25869c8dbc7bb71927b7ea61f81c (patch) | |
| tree | b00bfc952998bf1d3073ea80e382d782ebbb2106 | |
| parent | 5252885494079cf28a337644a87e61b19340f09c (diff) | |
[1.6.x] Fixed #21235 -- Disabled savepoints for old versions of SQLite.
Thanks Ramiro for the report.
Backport of 91547772 from master.
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 89c9ef1afa..96b03149d7 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -367,12 +367,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: |
