diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-06-14 22:56:21 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-06-14 22:56:21 -0400 |
| commit | 8f7766cc61479f3c9220c640230eeecd3d49ccc8 (patch) | |
| tree | 93476645904fd6ae7328b90c727ad2321030db88 /lib/sqlalchemy/sql/schema.py | |
| parent | b1fcd837974a052e46455af99e0a1f18f7074bd8 (diff) | |
| download | sqlalchemy-8f7766cc61479f3c9220c640230eeecd3d49ccc8.tar.gz | |
Lookup index columns in parent table by key for copy
Fixed regression in 1.2 due to :ticket:`4147` where a :class:`.Table` that
has had some of its indexed columns redefined with new ones, as would occur
when overriding columns during reflection or when using
:paramref:`.Table.extend_existing`, such that the :meth:`.Table.tometadata`
method would fail when attempting to copy those indexes as they still
referred to the replaced column. The copy logic now accommodates for this
condition.
Change-Id: I521aa2c9f3baa0e84598bbdd6ffe4bf07b6e3ba8
Fixes: #4279
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 1d6bc4c61..88050b87e 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -69,7 +69,8 @@ def _get_table_key(name, schema): # break an import cycle def _copy_expression(expression, source_table, target_table): def replace(col): - if source_table.c.contains_column(col): + if isinstance(col, Column) and \ + col.table is source_table and col.key in source_table.c: return target_table.c[col.key] else: return None |
