Ticket #766 (closed defect: fixed)
db.delete_column() not worked for mysql 5.5 when the column is a foreign key
|Reported by:||lgs@…||Owned by:||andrew|
The problem is that there is a subtle typo in the mysql.py code that checks if there is a foreign key constraint in that column:
@generic.delete_column_constraints def delete_column(self, table_name, name): db_name = self._get_setting('NAME') # See if there is a foreign key on this column result = 0 for kind, cname in self.lookup_constraint(db_name, table_name, name): if kind == 'FOREIGN KEY': result += 1 fkey_name = cname if result: assert result == 1 # We should only have one result, otherwise there's Issues cursor = self._get_connection().cursor() drop_query = "ALTER TABLE %s DROP FOREIGN KEY %s" cursor.execute(drop_query % (self.quote_name(table_name), self.quote_name(fkey_name))) super(DatabaseOperations, self).delete_column(table_name, name)
The if kind == 'FOREIGN_KEY' should be if kind == 'FOREIGN KEY'
Note the underscore.