diff options
author | TilmanK <tilman.krummeck@googlemail.com> | 2021-09-14 15:39:59 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-09-17 09:26:59 -0400 |
commit | 4abcbcd56ae1a657334195a18c46bd6b3d5e444a (patch) | |
tree | 6a8b2406c7b46aac0780e470c772c0d762fb27f2 | |
parent | a2a9e197ca41bc9f5f61ff22646485871348e8da (diff) | |
download | alembic-4abcbcd56ae1a657334195a18c46bd6b3d5e444a.tar.gz |
Fix constraint_name type of create_foreign_key
Fixed type annotations for the "constraint_name" argument of operations
``create_primary_key()``, ``create_foreign_key()``. Pull request courtesy
TilmanK.
Closes: #914
Pull-request: https://github.com/sqlalchemy/alembic/pull/914
Pull-request-sha: 39d44af226b2103da3964daf3229880a0958b97c
Change-Id: Iec4b392c70ae0eeda06dcbfda95a2f044e976686
-rw-r--r-- | alembic/op.pyi | 18 | ||||
-rw-r--r-- | alembic/operations/ops.py | 18 | ||||
-rw-r--r-- | docs/build/unreleased/914.rst | 8 |
3 files changed, 26 insertions, 18 deletions
diff --git a/alembic/op.pyi b/alembic/op.pyi index f5aca92..2a03e1e 100644 --- a/alembic/op.pyi +++ b/alembic/op.pyi @@ -508,7 +508,7 @@ def create_exclude_constraint( """ def create_foreign_key( - constraint_name: str, + constraint_name: Optional[str], source_table: str, referent_table: str, local_cols: List[str], @@ -541,9 +541,9 @@ def create_foreign_key( off normally. The :class:`~sqlalchemy.schema.AddConstraint` construct is ultimately used to generate the ALTER statement. - :param name: Name of the foreign key constraint. The name is necessary - so that an ALTER statement can be emitted. For setups that - use an automated naming scheme such as that described at + :param constraint_name: Name of the foreign key constraint. The name + is necessary so that an ALTER statement can be emitted. For setups + that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions`, ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated @@ -618,7 +618,7 @@ def create_index( """ def create_primary_key( - constraint_name: str, + constraint_name: Optional[str], table_name: str, columns: List[str], schema: Optional[str] = None, @@ -643,9 +643,9 @@ def create_primary_key( off normally. The :class:`~sqlalchemy.schema.AddConstraint` construct is ultimately used to generate the ALTER statement. - :param name: Name of the primary key constraint. The name is necessary - so that an ALTER statement can be emitted. For setups that - use an automated naming scheme such as that described at + :param constraint_name: Name of the primary key constraint. The name + is necessary so that an ALTER statement can be emitted. For setups + that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions` ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated @@ -1002,7 +1002,7 @@ def execute( op.execute("INSERT INTO table (foo) VALUES ('\:colon_value')") - :param sql: Any legal SQLAlchemy expression, including: + :param sqltext: Any legal SQLAlchemy expression, including: * a string * a :func:`sqlalchemy.sql.expression.text` construct. diff --git a/alembic/operations/ops.py b/alembic/operations/ops.py index d5ddbc9..7d69f09 100644 --- a/alembic/operations/ops.py +++ b/alembic/operations/ops.py @@ -296,7 +296,7 @@ class CreatePrimaryKeyOp(AddConstraintOp): def create_primary_key( cls, operations: "Operations", - constraint_name: str, + constraint_name: Optional[str], table_name: str, columns: List[str], schema: Optional[str] = None, @@ -321,9 +321,9 @@ class CreatePrimaryKeyOp(AddConstraintOp): off normally. The :class:`~sqlalchemy.schema.AddConstraint` construct is ultimately used to generate the ALTER statement. - :param name: Name of the primary key constraint. The name is necessary - so that an ALTER statement can be emitted. For setups that - use an automated naming scheme such as that described at + :param constraint_name: Name of the primary key constraint. The name + is necessary so that an ALTER statement can be emitted. For setups + that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions` ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated @@ -588,7 +588,7 @@ class CreateForeignKeyOp(AddConstraintOp): def create_foreign_key( cls, operations: "Operations", - constraint_name: str, + constraint_name: Optional[str], source_table: str, referent_table: str, local_cols: List[str], @@ -621,9 +621,9 @@ class CreateForeignKeyOp(AddConstraintOp): off normally. The :class:`~sqlalchemy.schema.AddConstraint` construct is ultimately used to generate the ALTER statement. - :param name: Name of the foreign key constraint. The name is necessary - so that an ALTER statement can be emitted. For setups that - use an automated naming scheme such as that described at + :param constraint_name: Name of the foreign key constraint. The name + is necessary so that an ALTER statement can be emitted. For setups + that use an automated naming scheme such as that described at :ref:`sqla:constraint_naming_conventions`, ``name`` here can be ``None``, as the event listener will apply the name to the constraint object when it is associated @@ -2389,7 +2389,7 @@ class ExecuteSQLOp(MigrateOperation): op.execute("INSERT INTO table (foo) VALUES ('\:colon_value')") - :param sql: Any legal SQLAlchemy expression, including: + :param sqltext: Any legal SQLAlchemy expression, including: * a string * a :func:`sqlalchemy.sql.expression.text` construct. diff --git a/docs/build/unreleased/914.rst b/docs/build/unreleased/914.rst new file mode 100644 index 0000000..cbc9f34 --- /dev/null +++ b/docs/build/unreleased/914.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, mypy + :tickets: 914 + + Fixed type annotations for the "constraint_name" argument of operations + ``create_primary_key()``, ``create_foreign_key()``. Pull request courtesy + TilmanK. + |