diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-04-07 11:05:20 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2023-04-07 11:05:20 -0400 |
commit | 1ae44556907f14f92874f05d05242cb57bb0f855 (patch) | |
tree | 5e744b2c671fdf74be1b613cd5bc145f081fd213 /alembic/operations | |
parent | 3d9b1128cd6bf03ecb45003587c0eedfb9552b07 (diff) | |
download | alembic-1ae44556907f14f92874f05d05242cb57bb0f855.tar.gz |
uniquify cols for FK table object
Fixed issue where using a directive such as ``op.create_foreign_key()`` to
create a self-referential constraint on a single table where the same
column were present on both sides (e.g. within a composite foreign key)
would produce an error under SQLAlchemy 2.0 and a warning under SQLAlchemy
1.4 indicating that a duplicate column were being added to a table.
Change-Id: I2a8f5d8def2714792bffcdfb8bf88a5080ec8ce7
Fixes: #1215
Diffstat (limited to 'alembic/operations')
-rw-r--r-- | alembic/operations/schemaobj.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/alembic/operations/schemaobj.py b/alembic/operations/schemaobj.py index 0568471..799f113 100644 --- a/alembic/operations/schemaobj.py +++ b/alembic/operations/schemaobj.py @@ -89,7 +89,10 @@ class SchemaObjects: t1 = sa_schema.Table( source, m, - *[sa_schema.Column(n, NULLTYPE) for n in t1_cols], + *[ + sa_schema.Column(n, NULLTYPE) + for n in util.unique_list(t1_cols) + ], schema=source_schema, ) |