Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #21235 -- Disabled savepoints for old versions of SQLite.

Thanks Ramiro for the report.
  • Loading branch information...
commit 91547772e04e456f45c7ef86e1f76d087821c89d 1 parent 8d75d1e
Aymeric Augustin authored October 07, 2013

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. 10  django/db/backends/sqlite3/base.py
10  django/db/backends/sqlite3/base.py
@@ -393,12 +393,16 @@ def close(self):
393 393
             BaseDatabaseWrapper.close(self)
394 394
 
395 395
     def _savepoint_allowed(self):
  396
+        # Two conditions are required here:
  397
+        # - A sufficiently recent version of SQLite to support savepoints,
  398
+        # - Being in a transaction, which can only happen inside 'atomic'.
  399
+
396 400
         # When 'isolation_level' is not None, sqlite3 commits before each
397 401
         # savepoint; it's a bug. When it is None, savepoints don't make sense
398  
-        # because autocommit is enabled. The only exception is inside atomic
399  
-        # blocks. To work around that bug, on SQLite, atomic starts a
  402
+        # because autocommit is enabled. The only exception is inside 'atomic'
  403
+        # blocks. To work around that bug, on SQLite, 'atomic' starts a
400 404
         # transaction explicitly rather than simply disable autocommit.
401  
-        return self.in_atomic_block
  405
+        return self.features.uses_savepoints and self.in_atomic_block
402 406
 
403 407
     def _set_autocommit(self, autocommit):
404 408
         if autocommit:

0 notes on commit 9154777

Please sign in to comment.
Something went wrong with that request. Please try again.