diff options
Diffstat (limited to 'alembic')
-rw-r--r-- | alembic/op.pyi | 4 | ||||
-rw-r--r-- | alembic/operations/base.py | 22 | ||||
-rw-r--r-- | alembic/operations/ops.py | 33 |
3 files changed, 51 insertions, 8 deletions
diff --git a/alembic/op.pyi b/alembic/op.pyi index a0f1d7e..8c672fa 100644 --- a/alembic/op.pyi +++ b/alembic/op.pyi @@ -387,6 +387,7 @@ def batch_alter_table( def bulk_insert( table: Union[Table, TableClause], rows: List[dict], + *, multiinsert: bool = True, ) -> None: """Issue a "bulk insert" operation using the current @@ -815,8 +816,8 @@ def create_table(table_name: str, *columns: SchemaItem, **kw: Any) -> Table: def create_table_comment( table_name: str, comment: Optional[str], - existing_comment: Optional[str] = None, *, + existing_comment: Optional[str] = None, schema: Optional[str] = None, ) -> None: """Emit a COMMENT ON operation to set the comment for a table. @@ -1024,6 +1025,7 @@ def drop_table_comment( def execute( sqltext: Union[str, TextClause, Update], + *, execution_options: Optional[dict[str, Any]] = None, ) -> None: r"""Execute the given SQL using the current migration context. diff --git a/alembic/operations/base.py b/alembic/operations/base.py index 1dd7aca..39dadda 100644 --- a/alembic/operations/base.py +++ b/alembic/operations/base.py @@ -765,6 +765,7 @@ class Operations(AbstractOperations): self, table: Union[Table, TableClause], rows: List[dict], + *, multiinsert: bool = True, ) -> None: """Issue a "bulk insert" operation using the current @@ -1211,8 +1212,8 @@ class Operations(AbstractOperations): self, table_name: str, comment: Optional[str], - existing_comment: Optional[str] = None, *, + existing_comment: Optional[str] = None, schema: Optional[str] = None, ) -> None: """Emit a COMMENT ON operation to set the comment for a table. @@ -1433,6 +1434,7 @@ class Operations(AbstractOperations): def execute( self, sqltext: Union[str, TextClause, Update], + *, execution_options: Optional[dict[str, Any]] = None, ) -> None: r"""Execute the given SQL using the current migration context. @@ -1739,6 +1741,7 @@ class BatchOperations(AbstractOperations): def create_table_comment( self, comment: Optional[str], + *, existing_comment: Optional[str] = None, ) -> None: """Emit a COMMENT ON operation to set the comment for a table @@ -1811,7 +1814,7 @@ class BatchOperations(AbstractOperations): ... def drop_table_comment( - self, existing_comment: Optional[str] = None + self, *, existing_comment: Optional[str] = None ) -> None: """Issue a "drop table comment" operation to remove an existing comment set on a table using the current @@ -1825,4 +1828,19 @@ class BatchOperations(AbstractOperations): """ # noqa: E501 ... + def execute( + self, + sqltext: Union[str, TextClause, Update], + *, + execution_options: Optional[dict[str, Any]] = None, + ) -> None: + """Execute the given SQL using the current migration context. + + .. seealso:: + + :meth:`.Operations.execute` + + """ # noqa: E501 + ... + # END STUB FUNCTIONS: batch_op diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py index 1fede52..05c01aa 100644 --- a/alembic/operations/ops.py +++ b/alembic/operations/ops.py @@ -174,9 +174,7 @@ class DropConstraintOp(MigrateOperation): _reverse=AddConstraintOp.from_constraint(constraint), ) - def to_constraint( - self, - ) -> Constraint: + def to_constraint(self) -> Constraint: if self._reverse is not None: constraint = self._reverse.to_constraint() @@ -1453,8 +1451,8 @@ class CreateTableCommentOp(AlterTableOp): operations: Operations, table_name: str, comment: Optional[str], - existing_comment: Optional[str] = None, *, + existing_comment: Optional[str] = None, schema: Optional[str] = None, ) -> None: """Emit a COMMENT ON operation to set the comment for a table. @@ -1490,6 +1488,7 @@ class CreateTableCommentOp(AlterTableOp): cls, operations: BatchOperations, comment: Optional[str], + *, existing_comment: Optional[str] = None, ) -> None: """Emit a COMMENT ON operation to set the comment for a table @@ -1592,6 +1591,7 @@ class DropTableCommentOp(AlterTableOp): def batch_drop_table_comment( cls, operations: BatchOperations, + *, existing_comment: Optional[str] = None, ) -> None: """Issue a "drop table comment" operation to @@ -2293,6 +2293,7 @@ class BulkInsertOp(MigrateOperation): self, table: Union[Table, TableClause], rows: List[dict], + *, multiinsert: bool = True, ) -> None: self.table = table @@ -2305,6 +2306,7 @@ class BulkInsertOp(MigrateOperation): operations: Operations, table: Union[Table, TableClause], rows: List[dict], + *, multiinsert: bool = True, ) -> None: """Issue a "bulk insert" operation using the current @@ -2408,13 +2410,14 @@ class BulkInsertOp(MigrateOperation): @Operations.register_operation("execute") -@BatchOperations.register_operation("execute") +@BatchOperations.register_operation("execute", "batch_execute") class ExecuteSQLOp(MigrateOperation): """Represent an execute SQL operation.""" def __init__( self, sqltext: Union[Update, str, Insert, TextClause], + *, execution_options: Optional[dict[str, Any]] = None, ) -> None: self.sqltext = sqltext @@ -2425,6 +2428,7 @@ class ExecuteSQLOp(MigrateOperation): cls, operations: Operations, sqltext: Union[str, TextClause, Update], + *, execution_options: Optional[dict[str, Any]] = None, ) -> None: r"""Execute the given SQL using the current migration context. @@ -2511,6 +2515,25 @@ class ExecuteSQLOp(MigrateOperation): op = cls(sqltext, execution_options=execution_options) return operations.invoke(op) + @classmethod + def batch_execute( + cls, + operations: Operations, + sqltext: Union[str, TextClause, Update], + *, + execution_options: Optional[dict[str, Any]] = None, + ) -> None: + """Execute the given SQL using the current migration context. + + .. seealso:: + + :meth:`.Operations.execute` + + """ + return cls.execute( + operations, sqltext, execution_options=execution_options + ) + class OpContainer(MigrateOperation): """Represent a sequence of operations operation.""" |