summaryrefslogtreecommitdiff
path: root/alembic/operations
diff options
context:
space:
mode:
authorNicolas CANIART <nicolas.caniart@jobteaser.com>2022-03-13 12:39:40 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-03-14 15:12:47 -0400
commitce6144efc6648986733fb9bbb981e95a4a739f61 (patch)
tree4caa38f234748b7e8398d10a618b1198cbd784bd /alembic/operations
parent721b28ce889e63e49b8be1a1bd62b7d3bb3b7526 (diff)
downloadalembic-ce6144efc6648986733fb9bbb981e95a4a739f61.tar.gz
Fix duplicated constraints when using expressions
Fixed issue where using :meth:`.Operations.create_table` in conjunction with a :class:`.CheckConstraint` that referred to table-bound :class:`.Column` objects rather than string expressions would be added to the parent table twice, resulting in an incorrect DDL sequence. Pull request courtesy Nicolas CANIART. Fixes: #1004 Closes: #1005 Pull-request: https://github.com/sqlalchemy/alembic/pull/1005 Pull-request-sha: 2fe5c5297bcde990096571a047039c451aa876f6 Change-Id: I2bf48701968fe59a6766f8f8879320b1bfd75774
Diffstat (limited to 'alembic/operations')
-rw-r--r--alembic/operations/schemaobj.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/alembic/operations/schemaobj.py b/alembic/operations/schemaobj.py
index c8fab93..0a27920 100644
--- a/alembic/operations/schemaobj.py
+++ b/alembic/operations/schemaobj.py
@@ -214,7 +214,8 @@ class SchemaObjects:
constraints = [
sqla_compat._copy(elem, target_table=t)
- if getattr(elem, "parent", None) is not None
+ if getattr(elem, "parent", None) is not t
+ and getattr(elem, "parent", None) is not None
else elem
for elem in columns
if isinstance(elem, (Constraint, Index))