]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Fixed mssql_* kwargs in batch_op.drop_column().
authorMichal Petrucha <michal.petrucha@ksp.sk>
Thu, 21 Jan 2016 10:13:56 +0000 (11:13 +0100)
committerMichal Petrucha <michal.petrucha@ksp.sk>
Thu, 21 Jan 2016 10:13:56 +0000 (11:13 +0100)
alembic/operations/ops.py
tests/test_mssql.py

index 839c2da296fba301c5df66323f7e649e85efe796..dbae84b40c724767e608f3a9e191ef80a5ca88f7 100644 (file)
@@ -1637,7 +1637,7 @@ class DropColumnOp(AlterTableOp):
         return operations.invoke(op)
 
     @classmethod
-    def batch_drop_column(cls, operations, column_name):
+    def batch_drop_column(cls, operations, column_name, **kw):
         """Issue a "drop column" instruction using the current
         batch migration context.
 
@@ -1648,7 +1648,7 @@ class DropColumnOp(AlterTableOp):
         """
         op = cls(
             operations.impl.table_name, column_name,
-            schema=operations.impl.schema)
+            schema=operations.impl.schema, **kw)
         return operations.invoke(op)
 
 
index 0ec18e2b0a6109888c4e3878e4edb33aa328d371..ce91f99939e54c0ae01510b8c804aa9191b12ec5 100644 (file)
@@ -109,6 +109,15 @@ class OpTest(TestBase):
             "exec('alter table t1 drop constraint ' + @const_name)")
         context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
 
+    def test_drop_column_w_default_in_batch(self):
+        context = op_fixture('mssql')
+        with op.batch_alter_table('t1', schema=None) as batch_op:
+            batch_op.drop_column('c1', mssql_drop_default=True)
+            batch_op.drop_column('c2', mssql_drop_default=True)
+        context.assert_contains(
+            "exec('alter table t1 drop constraint ' + @const_name)")
+        context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+
     def test_alter_column_drop_default(self):
         context = op_fixture('mssql')
         op.alter_column("t", "c", server_default=None)
@@ -133,6 +142,15 @@ class OpTest(TestBase):
             "exec('alter table t1 drop constraint ' + @const_name)")
         context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
 
+    def test_drop_column_w_check_in_batch(self):
+        context = op_fixture('mssql')
+        with op.batch_alter_table('t1', schema=None) as batch_op:
+            batch_op.drop_column('c1', mssql_drop_check=True)
+            batch_op.drop_column('c2', mssql_drop_check=True)
+        context.assert_contains(
+            "exec('alter table t1 drop constraint ' + @const_name)")
+        context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+
     def test_drop_column_w_check_quoting(self):
         context = op_fixture('mssql')
         op.drop_column('table', 'column', mssql_drop_check=True)
@@ -154,6 +172,14 @@ class OpTest(TestBase):
             "exec('alter table t1 drop constraint ' + @const_name)")
         context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
 
+    def test_drop_column_w_fk_in_batch(self):
+        context = op_fixture('mssql')
+        with op.batch_alter_table('t1', schema=None) as batch_op:
+            batch_op.drop_column('c1', mssql_drop_foreign_key=True)
+        context.assert_contains(
+            "exec('alter table t1 drop constraint ' + @const_name)")
+        context.assert_contains("ALTER TABLE t1 DROP COLUMN c1")
+
     def test_alter_column_not_nullable_w_existing_type(self):
         context = op_fixture('mssql')
         op.alter_column("t", "c", nullable=False, existing_type=Integer)