[Sqlalchemy-tickets] Issue #3298: When using "Overriding Reflected Columns" feature, foreign key c
Brought to you by:
zzzeek
|
From: Armin G. <iss...@bi...> - 2015-01-27 15:11:22
|
New issue 3298: When using "Overriding Reflected Columns" feature, foreign key constraints fails when (auto-)generating relationship properties https://bitbucket.org/zzzeek/sqlalchemy/issue/3298/when-using-overriding-reflected-columns Armin Gruner: Hi, if I change some property names distinct from the table column names according to http://docs.sqlalchemy.org/en/rel_0_9/core/reflection.html?highlight=column%20reflect#sqlalchemy.engine.reflection.Inspector.get_columns, I get an error later when preparing the automap base: ``` #!python @event.listens_for(Table, 'column_reflect') def receive_column_reflect(inspector, table, column_info): name = column_info["name"] column_info["key"] = name.lower() def setup(): Base.metadata.reflect(engine, extend_existing=True, autoload_replace=False) Base.prepare(engine) ``` NoReferencedColumnError: Could not initialize target column for ForeignKey 'ABSTRACT_FORWARD_DESTINATION.ID' on table 'TRUNK': table 'ABSTRACT_FORWARD_DESTINATION' has no column named 'ID' If I disable the code inside the column reflection listener, SQLAlchemy 0.9.8 properly reflects all tables, creates object classes and relations. |