Commits

Atsushi Odagiri  committed 45f3704

#44 workaround

  • Participants
  • Parent commits 211255a
  • Branches mysql_constraints

Comments (0)

Files changed (2)

File alembic/operations.py

         # 0.7.6 and further raises on Index with no columns
         self.impl.drop_index(self._index(name, tablename, ['x']))
 
-    def drop_constraint(self, name, tablename):
+    def drop_constraint(self, name, tablename, constraint=None):
         """Drop a constraint of the given name"""
         t = self._table(tablename)
-        const = schema.Constraint(name=name)
+        #const = schema.Constraint(name=name)
+        if constraint is None:
+            constraint = schema.Constraint
+        const = constraint(name=name)
         t.append_constraint(const)
         self.impl.drop_constraint(const)
 

File tests/test_mysql.py

 from sqlalchemy import Integer, Column, ForeignKey, \
             UniqueConstraint, Table, MetaData, String
 from sqlalchemy.sql import table
+from sqlalchemy.schema import ForeignKeyConstraint
 
 def test_rename_column():
     context = op_fixture('mysql')
 
 def test_drop_foreign_key():
     context = op_fixture('mysql')
-    op.drop_constraint('fk_id', 't1')
+    op.drop_constraint('fk_id', 't1', constraint=lambda name: ForeignKeyConstraint([], [], name=name))
     context.assert_(
         "ALTER TABLE t1 DROP FOREIGN KEY fk_id"
     )