Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.6.x] Fixed #21235 -- Disabled savepoints for old versions of SQLite.

Thanks Ramiro for the report.

Backport of 9154777 from master.
  • Loading branch information...
commit b42f0665a8cc25869c8dbc7bb71927b7ea61f81c 1 parent 5252885
@aaugustin aaugustin authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 django/db/backends/sqlite3/base.py
View
10 django/db/backends/sqlite3/base.py
@@ -367,12 +367,16 @@ def close(self):
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:
Please sign in to comment.
Something went wrong with that request. Please try again.