- changed status to resolved
columns added to a joined table (typically with declarative) after the mappings
Issue #1523
resolved
patch:
Index: lib/sqlalchemy/orm/mapper.py
===================================================================
--- lib/sqlalchemy/orm/mapper.py (revision 6293)
+++ lib/sqlalchemy/orm/mapper.py (working copy)
@@ -547,9 +547,17 @@
for c in columns:
mc = self.mapped_table.corresponding_column(c)
if not mc:
- raise sa_exc.ArgumentError("Column '%s' is not represented in mapper's table. "
- "Use the `column_property()` function to force this column "
- "to be mapped as a read-only attribute." % c)
+ mc = self.local_table.corresponding_column(c)
+ if mc:
+ # if the column is in the local table but not the mapped table,
+ # this corresponds to adding a column after the fact to the local table.
+ self.mapped_table._reset_exported()
+ mc = self.mapped_table.corresponding_column(c)
+ if not mc:
+ raise sa_exc.ArgumentError("Column '%s' is not represented in mapper's table. "
+ "Use the `column_property()` function to force this column "
+ "to be mapped as a read-only attribute." % c)
+
mapped_column.append(mc)
prop = ColumnProperty(*mapped_column)
else:
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: 0.5.6 (automated comment)
- Log in to comment
4888c89ce53b35994f2d8b4a1116fd9d7c2a5804 2f91c12a2edb8694d56b6c8a6a9b3eeeb12a5556