]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Fix constraint_name type of create_foreign_key
authorTilmanK <tilman.krummeck@googlemail.com>
Tue, 14 Sep 2021 19:39:59 +0000 (15:39 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 17 Sep 2021 13:26:59 +0000 (09:26 -0400)
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

alembic/op.pyi
alembic/operations/ops.py
docs/build/unreleased/914.rst [new file with mode: 0644]

index f5aca925375ade91ed203ad1ddf2b8f08b2dc29d..2a03e1e27ade2e4e000adfe48809973e90e5bf8e 100644 (file)
@@ -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.
index d5ddbc94df946649cdc7231c50cfefa6ed4d888a..7d69f0932d3f33ae37fa403c76f9049241026259 100644 (file)
@@ -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 (file)
index 0000000..cbc9f34
--- /dev/null
@@ -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.
+