Commits

Andrew Godwin committed e1867ac

Fixed #967: Set foreign key checks to 0 at the start of every transaction on MySQL.

  • Participants
  • Parent commits 24cadba

Comments (0)

Files changed (1)

File south/db/mysql.py

         cursor = self._get_connection().cursor()
         if self._has_setting('STORAGE_ENGINE') and self._get_setting('STORAGE_ENGINE'):
             cursor.execute("SET storage_engine=%s;" % self._get_setting('STORAGE_ENGINE'))
-        # Turn off foreign key checks, and turn them back on at the end
-        cursor.execute("SET FOREIGN_KEY_CHECKS=0;")
-        self.deferred_sql.append("SET FOREIGN_KEY_CHECKS=1;")
+
+    def start_transaction(self):
+        super(DatabaseOperations, self).start_transaction()
+        self.execute("SET FOREIGN_KEY_CHECKS=0;")
 
     @copy_column_constraints
     @delete_column_constraints