Ticket #15507: mysql-savepoints.diff

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

    diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
    index 98233c7..87e7d2a 100644
    a b class DatabaseOperations(BaseDatabaseOperations):  
    255255    def max_name_length(self):
    256256        return 64
    257257
     258    def savepoint_create_sql(self, sid):
     259        return "SAVEPOINT %s" % sid
     260
     261    def savepoint_commit_sql(self, sid):
     262        return "RELEASE SAVEPOINT %s" % sid
     263
     264    def savepoint_rollback_sql(self, sid):
     265        return "ROLLBACK TO SAVEPOINT %s" % sid
     266
    258267class DatabaseWrapper(BaseDatabaseWrapper):
    259268    vendor = 'mysql'
    260269    operators = {
    class DatabaseWrapper(BaseDatabaseWrapper):  
    322331            self.connection = Database.connect(**kwargs)
    323332            self.connection.encoders[SafeUnicode] = self.connection.encoders[unicode]
    324333            self.connection.encoders[SafeString] = self.connection.encoders[str]
     334            self.features.uses_savepoints = \
     335                self.get_server_version() >= (5, 0, 3)
    325336            connection_created.send(sender=self.__class__, connection=self)
    326337        cursor = CursorWrapper(self.connection.cursor())
    327338        return cursor
Back to Top