Ticket #15506: sqlite-savepoints.diff

File sqlite-savepoints.diff, 1.3 KB (added by Chris Lamb, 14 years ago)
  • django/db/backends/sqlite3/base.py

    diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
    index 8344bad..1cdabff 100644
    a b class DatabaseOperations(BaseDatabaseOperations):  
    161161        # No field, or the field isn't known to be a decimal or integer
    162162        return value
    163163
     164    def savepoint_create_sql(self, sid):
     165        return "SAVEPOINT %s" % sid
     166
     167    def savepoint_commit_sql(self, sid):
     168        return "RELEASE SAVEPOINT %s" % sid
     169
     170    def savepoint_rollback_sql(self, sid):
     171        return "ROLLBACK TO SAVEPOINT %s" % sid
     172
    164173class DatabaseWrapper(BaseDatabaseWrapper):
    165174    vendor = 'sqlite'
    166175    # SQLite requires LIKE statements to include an ESCAPE clause if the value
    class DatabaseWrapper(BaseDatabaseWrapper):  
    211220            self.connection.create_function("regexp", 2, _sqlite_regexp)
    212221            self.connection.create_function("django_format_dtdelta", 5, _sqlite_format_dtdelta)
    213222            connection_created.send(sender=self.__class__, connection=self)
     223
     224        # We can only enable savepoints if the user has specified the
     225        # "autocommit" mode.
     226        self.features.uses_savepoints = self.connection.isolation_level is None
     227
    214228        return self.connection.cursor(factory=SQLiteCursorWrapper)
    215229
    216230    def close(self):
Back to Top