]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
keyword only arguments in ops
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 25 Nov 2022 15:31:20 +0000 (10:31 -0500)
committerFederico Caselli <cfederico87@gmail.com>
Thu, 11 May 2023 20:24:53 +0000 (22:24 +0200)
Argument signatures of Alembic operations now enforce keyword-only
arguments as passed as keyword and not positionally, such as
:paramref:`.Operations.create_table.schema`,
:paramref:`.Operations.add_column.type_`, etc.

Change-Id: I91b453c8848dc5d24d63840bfd7ce4d22dd0e693
Fixes: #1130
alembic/op.pyi
alembic/operations/base.py
alembic/operations/ops.py
docs/build/unreleased/1130.rst [new file with mode: 0644]
tests/test_batch.py
tests/test_mssql.py
tests/test_mysql.py
tests/test_oracle.py
tests/test_postgresql.py

index aa3ad2d9d10b1cbe6883d5848d139ed08ec2c075..13e0c3dafc1325c23461a30e5926bd57b1ceab48 100644 (file)
@@ -41,7 +41,7 @@ if TYPE_CHECKING:
 ### end imports ###
 
 def add_column(
-    table_name: str, column: Column, schema: Optional[str] = None
+    table_name: str, column: Column, *, schema: Optional[str] = None
 ) -> None:
     """Issue an "add column" instruction using the current
     migration context.
@@ -124,6 +124,7 @@ def add_column(
 def alter_column(
     table_name: str,
     column_name: str,
+    *,
     nullable: Optional[bool] = None,
     comment: Union[str, Literal[False], None] = False,
     server_default: Any = False,
@@ -484,6 +485,7 @@ def create_check_constraint(
     constraint_name: Optional[str],
     table_name: str,
     condition: Union[str, BinaryExpression, TextClause],
+    *,
     schema: Optional[str] = None,
     **kw: Any,
 ) -> None:
@@ -572,6 +574,7 @@ def create_foreign_key(
     referent_table: str,
     local_cols: List[str],
     remote_cols: List[str],
+    *,
     onupdate: Optional[str] = None,
     ondelete: Optional[str] = None,
     deferrable: Optional[bool] = None,
@@ -635,6 +638,7 @@ def create_index(
     index_name: Optional[str],
     table_name: str,
     columns: Sequence[Union[str, TextClause, Function[Any]]],
+    *,
     schema: Optional[str] = None,
     unique: bool = False,
     **kw: Any,
@@ -687,6 +691,7 @@ def create_primary_key(
     constraint_name: Optional[str],
     table_name: str,
     columns: List[str],
+    *,
     schema: Optional[str] = None,
 ) -> None:
     """Issue a "create primary key" instruction using the current
@@ -807,6 +812,7 @@ def create_table_comment(
     table_name: str,
     comment: Optional[str],
     existing_comment: Optional[str] = None,
+    *,
     schema: Optional[str] = None,
 ) -> None:
     """Emit a COMMENT ON operation to set the comment for a table.
@@ -833,6 +839,7 @@ def create_unique_constraint(
     constraint_name: Optional[str],
     table_name: str,
     columns: Sequence[str],
+    *,
     schema: Optional[str] = None,
     **kw: Any,
 ) -> Any:
@@ -875,7 +882,11 @@ def create_unique_constraint(
     """
 
 def drop_column(
-    table_name: str, column_name: str, schema: Optional[str] = None, **kw: Any
+    table_name: str,
+    column_name: str,
+    *,
+    schema: Optional[str] = None,
+    **kw: Any,
 ) -> None:
     """Issue a "drop column" instruction using the current
     migration context.
@@ -917,6 +928,7 @@ def drop_column(
 def drop_constraint(
     constraint_name: str,
     table_name: str,
+    *,
     type_: Optional[str] = None,
     schema: Optional[str] = None,
 ) -> None:
@@ -935,6 +947,7 @@ def drop_constraint(
 
 def drop_index(
     index_name: str,
+    *,
     table_name: Optional[str] = None,
     schema: Optional[str] = None,
     **kw: Any,
@@ -962,7 +975,7 @@ def drop_index(
     """
 
 def drop_table(
-    table_name: str, schema: Optional[str] = None, **kw: Any
+    table_name: str, *, schema: Optional[str] = None, **kw: Any
 ) -> None:
     r"""Issue a "drop table" instruction using the current
     migration context.
@@ -984,6 +997,7 @@ def drop_table(
 
 def drop_table_comment(
     table_name: str,
+    *,
     existing_comment: Optional[str] = None,
     schema: Optional[str] = None,
 ) -> None:
@@ -1226,7 +1240,7 @@ def register_operation(
     """
 
 def rename_table(
-    old_table_name: str, new_table_name: str, schema: Optional[str] = None
+    old_table_name: str, new_table_name: str, *, schema: Optional[str] = None
 ) -> None:
     """Emit an ALTER TABLE to rename a table.
 
index 6e45a11675fc8d924762529e98bbeaa7c8c97e67..cd577c1790d0b85034b86a8e4bb2b1804c3b4a06 100644 (file)
@@ -126,8 +126,13 @@ class AbstractOperations(util.ModuleClsProxy):
             else:
                 defaulted_vals = ()
 
+            defaulted_vals += tuple(spec[4])
+            # here, we are using formatargspec in a different way in order
+            # to get a string that will re-apply incoming arguments to a new
+            # function call
+
             apply_kw = inspect_formatargspec(
-                name_args,
+                name_args + spec[4],
                 spec[1],
                 spec[2],
                 defaulted_vals,
@@ -155,6 +160,7 @@ class AbstractOperations(util.ModuleClsProxy):
                     "doc": fn.__doc__,
                 }
             )
+
             globals_ = dict(globals())
             globals_.update({"op_cls": op_cls})
             lcl = {}
@@ -520,7 +526,11 @@ class Operations(AbstractOperations):
         # ### do not edit ###
 
         def add_column(
-            self, table_name: str, column: Column, schema: Optional[str] = None
+            self,
+            table_name: str,
+            column: Column,
+            *,
+            schema: Optional[str] = None,
         ) -> None:
             """Issue an "add column" instruction using the current
             migration context.
@@ -605,6 +615,7 @@ class Operations(AbstractOperations):
             self,
             table_name: str,
             column_name: str,
+            *,
             nullable: Optional[bool] = None,
             comment: Union[str, Literal[False], None] = False,
             server_default: Any = False,
@@ -817,6 +828,7 @@ class Operations(AbstractOperations):
             constraint_name: Optional[str],
             table_name: str,
             condition: Union[str, BinaryExpression, TextClause],
+            *,
             schema: Optional[str] = None,
             **kw: Any,
         ) -> None:
@@ -912,6 +924,7 @@ class Operations(AbstractOperations):
             referent_table: str,
             local_cols: List[str],
             remote_cols: List[str],
+            *,
             onupdate: Optional[str] = None,
             ondelete: Optional[str] = None,
             deferrable: Optional[bool] = None,
@@ -977,6 +990,7 @@ class Operations(AbstractOperations):
             index_name: Optional[str],
             table_name: str,
             columns: Sequence[Union[str, TextClause, Function[Any]]],
+            *,
             schema: Optional[str] = None,
             unique: bool = False,
             **kw: Any,
@@ -1031,6 +1045,7 @@ class Operations(AbstractOperations):
             constraint_name: Optional[str],
             table_name: str,
             columns: List[str],
+            *,
             schema: Optional[str] = None,
         ) -> None:
             """Issue a "create primary key" instruction using the current
@@ -1156,6 +1171,7 @@ class Operations(AbstractOperations):
             table_name: str,
             comment: Optional[str],
             existing_comment: Optional[str] = None,
+            *,
             schema: Optional[str] = None,
         ) -> None:
             """Emit a COMMENT ON operation to set the comment for a table.
@@ -1184,6 +1200,7 @@ class Operations(AbstractOperations):
             constraint_name: Optional[str],
             table_name: str,
             columns: Sequence[str],
+            *,
             schema: Optional[str] = None,
             **kw: Any,
         ) -> Any:
@@ -1230,6 +1247,7 @@ class Operations(AbstractOperations):
             self,
             table_name: str,
             column_name: str,
+            *,
             schema: Optional[str] = None,
             **kw: Any,
         ) -> None:
@@ -1275,6 +1293,7 @@ class Operations(AbstractOperations):
             self,
             constraint_name: str,
             table_name: str,
+            *,
             type_: Optional[str] = None,
             schema: Optional[str] = None,
         ) -> None:
@@ -1295,6 +1314,7 @@ class Operations(AbstractOperations):
         def drop_index(
             self,
             index_name: str,
+            *,
             table_name: Optional[str] = None,
             schema: Optional[str] = None,
             **kw: Any,
@@ -1323,7 +1343,7 @@ class Operations(AbstractOperations):
             ...
 
         def drop_table(
-            self, table_name: str, schema: Optional[str] = None, **kw: Any
+            self, table_name: str, *, schema: Optional[str] = None, **kw: Any
         ) -> None:
             r"""Issue a "drop table" instruction using the current
             migration context.
@@ -1347,6 +1367,7 @@ class Operations(AbstractOperations):
         def drop_table_comment(
             self,
             table_name: str,
+            *,
             existing_comment: Optional[str] = None,
             schema: Optional[str] = None,
         ) -> None:
@@ -1460,6 +1481,7 @@ class Operations(AbstractOperations):
             self,
             old_table_name: str,
             new_table_name: str,
+            *,
             schema: Optional[str] = None,
         ) -> None:
             """Emit an ALTER TABLE to rename a table.
@@ -1510,6 +1532,7 @@ class BatchOperations(AbstractOperations):
         def add_column(
             self,
             column: Column,
+            *,
             insert_before: Optional[str] = None,
             insert_after: Optional[str] = None,
         ) -> None:
@@ -1526,6 +1549,7 @@ class BatchOperations(AbstractOperations):
         def alter_column(
             self,
             column_name: str,
+            *,
             nullable: Optional[bool] = None,
             comment: Union[str, Literal[False], None] = False,
             server_default: Any = False,
@@ -1610,6 +1634,7 @@ class BatchOperations(AbstractOperations):
             referent_table: str,
             local_cols: List[str],
             remote_cols: List[str],
+            *,
             referent_schema: Optional[str] = None,
             onupdate: Optional[str] = None,
             ondelete: Optional[str] = None,
@@ -1718,7 +1743,7 @@ class BatchOperations(AbstractOperations):
             ...
 
         def drop_constraint(
-            self, constraint_name: str, type_: Optional[str] = None
+            self, constraint_name: str, *, type_: Optional[str] = None
         ) -> None:
             """Issue a "drop constraint" instruction using the
             current batch migration context.
index 99d21d9eb997f68b48e133c189cc65f7f914f19c..538c21e0a1015e7c31c2c999fe0fb45c34f26361 100644 (file)
@@ -132,6 +132,7 @@ class DropConstraintOp(MigrateOperation):
         self,
         constraint_name: Optional[sqla_compat._ConstraintNameDefined],
         table_name: str,
+        *,
         type_: Optional[str] = None,
         schema: Optional[str] = None,
         _reverse: Optional[AddConstraintOp] = None,
@@ -197,6 +198,7 @@ class DropConstraintOp(MigrateOperation):
         operations: Operations,
         constraint_name: str,
         table_name: str,
+        *,
         type_: Optional[str] = None,
         schema: Optional[str] = None,
     ) -> None:
@@ -221,6 +223,7 @@ class DropConstraintOp(MigrateOperation):
         cls,
         operations: BatchOperations,
         constraint_name: str,
+        *,
         type_: Optional[str] = None,
     ) -> None:
         """Issue a "drop constraint" instruction using the
@@ -258,6 +261,7 @@ class CreatePrimaryKeyOp(AddConstraintOp):
         constraint_name: Optional[sqla_compat._ConstraintNameDefined],
         table_name: str,
         columns: Sequence[str],
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> None:
@@ -299,6 +303,7 @@ class CreatePrimaryKeyOp(AddConstraintOp):
         constraint_name: Optional[str],
         table_name: str,
         columns: List[str],
+        *,
         schema: Optional[str] = None,
     ) -> None:
         """Issue a "create primary key" instruction using the current
@@ -335,7 +340,7 @@ class CreatePrimaryKeyOp(AddConstraintOp):
          :class:`~sqlalchemy.sql.elements.quoted_name`.
 
         """
-        op = cls(constraint_name, table_name, columns, schema)
+        op = cls(constraint_name, table_name, columns, schema=schema)
         return operations.invoke(op)
 
     @classmethod
@@ -380,6 +385,7 @@ class CreateUniqueConstraintOp(AddConstraintOp):
         constraint_name: Optional[sqla_compat._ConstraintNameDefined],
         table_name: str,
         columns: Sequence[str],
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> None:
@@ -431,6 +437,7 @@ class CreateUniqueConstraintOp(AddConstraintOp):
         constraint_name: Optional[str],
         table_name: str,
         columns: Sequence[str],
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> Any:
@@ -591,6 +598,7 @@ class CreateForeignKeyOp(AddConstraintOp):
         referent_table: str,
         local_cols: List[str],
         remote_cols: List[str],
+        *,
         onupdate: Optional[str] = None,
         ondelete: Optional[str] = None,
         deferrable: Optional[bool] = None,
@@ -675,6 +683,7 @@ class CreateForeignKeyOp(AddConstraintOp):
         referent_table: str,
         local_cols: List[str],
         remote_cols: List[str],
+        *,
         referent_schema: Optional[str] = None,
         onupdate: Optional[str] = None,
         ondelete: Optional[str] = None,
@@ -739,6 +748,7 @@ class CreateCheckConstraintOp(AddConstraintOp):
         constraint_name: Optional[sqla_compat._ConstraintNameDefined],
         table_name: str,
         condition: Union[str, TextClause, ColumnElement[Any]],
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> None:
@@ -782,6 +792,7 @@ class CreateCheckConstraintOp(AddConstraintOp):
         constraint_name: Optional[str],
         table_name: str,
         condition: Union[str, BinaryExpression, TextClause],
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> None:
@@ -867,6 +878,7 @@ class CreateIndexOp(MigrateOperation):
         index_name: Optional[str],
         table_name: str,
         columns: Sequence[Union[str, TextClause, ColumnElement[Any]]],
+        *,
         schema: Optional[str] = None,
         unique: bool = False,
         **kw: Any,
@@ -918,6 +930,7 @@ class CreateIndexOp(MigrateOperation):
         index_name: Optional[str],
         table_name: str,
         columns: Sequence[Union[str, TextClause, Function[Any]]],
+        *,
         schema: Optional[str] = None,
         unique: bool = False,
         **kw: Any,
@@ -1005,6 +1018,7 @@ class DropIndexOp(MigrateOperation):
     def __init__(
         self,
         index_name: Union[quoted_name, str, conv],
+        *,
         table_name: Optional[str] = None,
         schema: Optional[str] = None,
         _reverse: Optional[CreateIndexOp] = None,
@@ -1027,7 +1041,7 @@ class DropIndexOp(MigrateOperation):
         assert index.table is not None
         return cls(
             index.name,  # type: ignore[arg-type]
-            index.table.name,
+            table_name=index.table.name,
             schema=index.table.schema,
             _reverse=CreateIndexOp.from_index(index),
             **index.kwargs,
@@ -1053,6 +1067,7 @@ class DropIndexOp(MigrateOperation):
         cls,
         operations: Operations,
         index_name: str,
+        *,
         table_name: Optional[str] = None,
         schema: Optional[str] = None,
         **kw: Any,
@@ -1111,6 +1126,7 @@ class CreateTableOp(MigrateOperation):
         self,
         table_name: str,
         columns: Sequence[SchemaItem],
+        *,
         schema: Optional[str] = None,
         _namespace_metadata: Optional[MetaData] = None,
         _constraints_included: bool = False,
@@ -1136,7 +1152,7 @@ class CreateTableOp(MigrateOperation):
 
     @classmethod
     def from_table(
-        cls, table: Table, _namespace_metadata: Optional[MetaData] = None
+        cls, table: Table, *, _namespace_metadata: Optional[MetaData] = None
     ) -> CreateTableOp:
         if _namespace_metadata is None:
             _namespace_metadata = table.metadata
@@ -1271,6 +1287,7 @@ class DropTableOp(MigrateOperation):
     def __init__(
         self,
         table_name: str,
+        *,
         schema: Optional[str] = None,
         table_kw: Optional[MutableMapping[Any, Any]] = None,
         _reverse: Optional[CreateTableOp] = None,
@@ -1291,7 +1308,7 @@ class DropTableOp(MigrateOperation):
 
     @classmethod
     def from_table(
-        cls, table: Table, _namespace_metadata: Optional[MetaData] = None
+        cls, table: Table, *, _namespace_metadata: Optional[MetaData] = None
     ) -> DropTableOp:
         return cls(
             table.name,
@@ -1335,6 +1352,7 @@ class DropTableOp(MigrateOperation):
         cls,
         operations: Operations,
         table_name: str,
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> None:
@@ -1365,6 +1383,7 @@ class AlterTableOp(MigrateOperation):
     def __init__(
         self,
         table_name: str,
+        *,
         schema: Optional[str] = None,
     ) -> None:
         self.table_name = table_name
@@ -1379,6 +1398,7 @@ class RenameTableOp(AlterTableOp):
         self,
         old_table_name: str,
         new_table_name: str,
+        *,
         schema: Optional[str] = None,
     ) -> None:
         super().__init__(old_table_name, schema=schema)
@@ -1390,6 +1410,7 @@ class RenameTableOp(AlterTableOp):
         operations: Operations,
         old_table_name: str,
         new_table_name: str,
+        *,
         schema: Optional[str] = None,
     ) -> None:
         """Emit an ALTER TABLE to rename a table.
@@ -1417,6 +1438,7 @@ class CreateTableCommentOp(AlterTableOp):
         self,
         table_name: str,
         comment: Optional[str],
+        *,
         schema: Optional[str] = None,
         existing_comment: Optional[str] = None,
     ) -> None:
@@ -1432,6 +1454,7 @@ class CreateTableCommentOp(AlterTableOp):
         table_name: str,
         comment: Optional[str],
         existing_comment: Optional[str] = None,
+        *,
         schema: Optional[str] = None,
     ) -> None:
         """Emit a COMMENT ON operation to set the comment for a table.
@@ -1528,6 +1551,7 @@ class DropTableCommentOp(AlterTableOp):
     def __init__(
         self,
         table_name: str,
+        *,
         schema: Optional[str] = None,
         existing_comment: Optional[str] = None,
     ) -> None:
@@ -1540,6 +1564,7 @@ class DropTableCommentOp(AlterTableOp):
         cls,
         operations: Operations,
         table_name: str,
+        *,
         existing_comment: Optional[str] = None,
         schema: Optional[str] = None,
     ) -> None:
@@ -1611,6 +1636,7 @@ class AlterColumnOp(AlterTableOp):
         self,
         table_name: str,
         column_name: str,
+        *,
         schema: Optional[str] = None,
         existing_type: Optional[Any] = None,
         existing_server_default: Any = False,
@@ -1770,6 +1796,7 @@ class AlterColumnOp(AlterTableOp):
         operations: Operations,
         table_name: str,
         column_name: str,
+        *,
         nullable: Optional[bool] = None,
         comment: Optional[Union[str, Literal[False]]] = False,
         server_default: Any = False,
@@ -1896,6 +1923,7 @@ class AlterColumnOp(AlterTableOp):
         cls,
         operations: BatchOperations,
         column_name: str,
+        *,
         nullable: Optional[bool] = None,
         comment: Optional[Union[str, Literal[False]]] = False,
         server_default: Any = False,
@@ -1967,6 +1995,7 @@ class AddColumnOp(AlterTableOp):
         self,
         table_name: str,
         column: Column,
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> None:
@@ -2006,6 +2035,7 @@ class AddColumnOp(AlterTableOp):
         operations: Operations,
         table_name: str,
         column: Column,
+        *,
         schema: Optional[str] = None,
     ) -> None:
         """Issue an "add column" instruction using the current
@@ -2094,6 +2124,7 @@ class AddColumnOp(AlterTableOp):
         cls,
         operations: BatchOperations,
         column: Column,
+        *,
         insert_before: Optional[str] = None,
         insert_after: Optional[str] = None,
     ) -> None:
@@ -2130,6 +2161,7 @@ class DropColumnOp(AlterTableOp):
         self,
         table_name: str,
         column_name: str,
+        *,
         schema: Optional[str] = None,
         _reverse: Optional[AddColumnOp] = None,
         **kw: Any,
@@ -2188,6 +2220,7 @@ class DropColumnOp(AlterTableOp):
         operations: Operations,
         table_name: str,
         column_name: str,
+        *,
         schema: Optional[str] = None,
         **kw: Any,
     ) -> None:
@@ -2508,6 +2541,7 @@ class ModifyTableOps(OpContainer):
         self,
         table_name: str,
         ops: Sequence[MigrateOperation],
+        *,
         schema: Optional[str] = None,
     ) -> None:
         super().__init__(ops)
@@ -2605,6 +2639,7 @@ class MigrationScript(MigrateOperation):
         rev_id: Optional[str],
         upgrade_ops: UpgradeOps,
         downgrade_ops: DowngradeOps,
+        *,
         message: Optional[str] = None,
         imports: Set[str] = set(),
         head: Optional[str] = None,
diff --git a/docs/build/unreleased/1130.rst b/docs/build/unreleased/1130.rst
new file mode 100644 (file)
index 0000000..dc11eb9
--- /dev/null
@@ -0,0 +1,8 @@
+.. change::
+    :tags: change, py3k
+    :tickets: 1130
+
+    Argument signatures of Alembic operations now enforce keyword-only
+    arguments as passed as keyword and not positionally, such as
+    :paramref:`.Operations.create_table.schema`,
+    :paramref:`.Operations.add_column.type_`, etc.
index 52f9bafc9b4665fd9e5828a2c4d3191d009bf3d3..66d59fd441370e3555d6d90d118497d1e9b56137 100644 (file)
@@ -1778,7 +1778,7 @@ class BatchRoundTripTest(TestBase):
         with self.op.batch_alter_table(
             "ck_table", recreate=recreate
         ) as batch_op:
-            batch_op.drop_constraint("ck", "check")
+            batch_op.drop_constraint("ck", type_="check")
 
         ck_consts = inspect(self.conn).get_check_constraints("ck_table")
         eq_(ck_consts, [])
index 640e1685b534a33454b5b875ca2c1dfa0d17f06c..b785e2f1c99b7fc036a29109be72b51de1b7bc64 100644 (file)
@@ -158,7 +158,7 @@ class OpTest(TestBase):
 
     def test_drop_index(self):
         context = op_fixture("mssql")
-        op.drop_index("my_idx", "my_table")
+        op.drop_index("my_idx", table_name="my_table")
         context.assert_contains("DROP INDEX my_idx ON my_table")
 
     def test_drop_column_w_default(self):
index 92c1819f16a5478f4689d061e5994673c8875cdb..fd3b18585a929de71702440714e35c1d4a7cfe75 100644 (file)
@@ -396,12 +396,12 @@ class MySQLOpTest(TestBase):
 
     def test_drop_fk(self):
         context = op_fixture("mysql")
-        op.drop_constraint("f1", "t1", "foreignkey")
+        op.drop_constraint("f1", "t1", type_="foreignkey")
         context.assert_("ALTER TABLE t1 DROP FOREIGN KEY f1")
 
     def test_drop_fk_quoted(self):
         context = op_fixture("mysql")
-        op.drop_constraint("MyFk", "MyTable", "foreignkey")
+        op.drop_constraint("MyFk", "MyTable", type_="foreignkey")
         context.assert_("ALTER TABLE `MyTable` DROP FOREIGN KEY `MyFk`")
 
     def test_drop_constraint_primary(self):
@@ -411,32 +411,32 @@ class MySQLOpTest(TestBase):
 
     def test_drop_unique(self):
         context = op_fixture("mysql")
-        op.drop_constraint("f1", "t1", "unique")
+        op.drop_constraint("f1", "t1", type_="unique")
         context.assert_("ALTER TABLE t1 DROP INDEX f1")
 
     def test_drop_unique_quoted(self):
         context = op_fixture("mysql")
-        op.drop_constraint("MyUnique", "MyTable", "unique")
+        op.drop_constraint("MyUnique", "MyTable", type_="unique")
         context.assert_("ALTER TABLE `MyTable` DROP INDEX `MyUnique`")
 
     def test_drop_check_mariadb(self):
         context = op_fixture("mariadb")
-        op.drop_constraint("f1", "t1", "check")
+        op.drop_constraint("f1", "t1", type_="check")
         context.assert_("ALTER TABLE t1 DROP CONSTRAINT f1")
 
     def test_drop_check_quoted_mariadb(self):
         context = op_fixture("mariadb")
-        op.drop_constraint("MyCheck", "MyTable", "check")
+        op.drop_constraint("MyCheck", "MyTable", type_="check")
         context.assert_("ALTER TABLE `MyTable` DROP CONSTRAINT `MyCheck`")
 
     def test_drop_check_mysql(self):
         context = op_fixture("mysql")
-        op.drop_constraint("f1", "t1", "check")
+        op.drop_constraint("f1", "t1", type_="check")
         context.assert_("ALTER TABLE t1 DROP CHECK f1")
 
     def test_drop_check_quoted_mysql(self):
         context = op_fixture("mysql")
-        op.drop_constraint("MyCheck", "MyTable", "check")
+        op.drop_constraint("MyCheck", "MyTable", type_="check")
         context.assert_("ALTER TABLE `MyTable` DROP CHECK `MyCheck`")
 
     def test_drop_unknown(self):
@@ -448,7 +448,7 @@ class MySQLOpTest(TestBase):
             op.drop_constraint,
             "f1",
             "t1",
-            "typo",
+            type_="typo",
         )
 
     def test_drop_generic_constraint(self):
index f84c0e12f83f0a4b055f9410cbdfbda900b2e800..63ac1c4bc26801e6644df12b010af2913cc15720 100644 (file)
@@ -163,7 +163,7 @@ class OpTest(TestBase):
 
     def test_drop_index(self):
         context = op_fixture("oracle")
-        op.drop_index("my_idx", "my_table")
+        op.drop_index("my_idx", table_name="my_table")
         context.assert_contains("DROP INDEX my_idx")
 
     def test_drop_column_w_default(self):
index 77ed4dabfcefdb46e4eb065872645f7eff5364e2..4d17096e58a28013abbcc70d7a79409301bb9144 100644 (file)
@@ -122,9 +122,17 @@ class PostgresqlOpTest(TestBase):
         op.create_index("i", "t", ["c1", "c2"], unique=False)
         context.assert_("CREATE INDEX i ON t (c1, c2)")
 
-    def test_drop_index_postgresql_concurrently(self):
+    @config.combinations("include_table", "no_table", argnames="include_table")
+    def test_drop_index_postgresql_concurrently(self, include_table):
         context = op_fixture("postgresql")
-        op.drop_index("geocoded", "locations", postgresql_concurrently=True)
+        if include_table == "include_table":
+            op.drop_index(
+                "geocoded",
+                table_name="locations",
+                postgresql_concurrently=True,
+            )
+        else:
+            op.drop_index("geocoded", postgresql_concurrently=True)
         context.assert_("DROP INDEX CONCURRENTLY geocoded")
 
     def test_alter_column_type_using(self):