diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-01-10 16:32:17 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-01-10 16:32:17 -0500 |
commit | d12da7c187c7121870216526fb89c782be5dd8fd (patch) | |
tree | 21a14b6661e2f876656d795bbf45daa6225762a9 /alembic/ddl/base.py | |
parent | b908cf9ed36b9e309afcbce197d1db63c2f13d53 (diff) | |
download | alembic-d12da7c187c7121870216526fb89c782be5dd8fd.tar.gz |
- Fixed bug in foreign key autogenerate where if the in-Python table
used custom column keys (e.g. using the ``key='foo'`` kwarg to
``Column``), the comparison of existing foreign keys to those specified
in the metadata would fail, as the reflected table would not have
these keys available which to match up. Foreign key comparison for
autogenerate now ensures it's looking at the database-side names
of the columns in all cases; this matches the same functionality
within unique constraints and indexes.
fixes #260
Diffstat (limited to 'alembic/ddl/base.py')
-rw-r--r-- | alembic/ddl/base.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/alembic/ddl/base.py b/alembic/ddl/base.py index d497253..dbdc991 100644 --- a/alembic/ddl/base.py +++ b/alembic/ddl/base.py @@ -172,10 +172,11 @@ def _columns_for_constraint(constraint): def _fk_spec(constraint): if util.sqla_100: - source_columns = constraint.column_keys + source_columns = [ + constraint.columns[key].name for key in constraint.column_keys] else: source_columns = [ - element.parent.key for element in constraint.elements] + element.parent.name for element in constraint.elements] source_table = constraint.parent.name source_schema = constraint.parent.schema |