diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-07-13 15:39:04 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-07-13 15:39:04 -0400 |
commit | b68c9ac93eea62a1f4ae2c0701e5af7c432e9432 (patch) | |
tree | 8f28219ba9c66064bcae6f32d50c88be3998c3b4 /lib/sqlalchemy/ext/declarative/api.py | |
parent | cadc2e0ba00feadf7e860598030bda0fb8bc691c (diff) | |
download | sqlalchemy-b68c9ac93eea62a1f4ae2c0701e5af7c432e9432.tar.gz |
- Fixed bug in :class:`.AbstractConcreteBase` extension where
a column setup on the ABC base which had a different attribute
name vs. column name would not be correctly mapped on the final
base class. The failure on 0.9 would be silent whereas on
1.0 it raised an ArgumentError, so may not have been noticed
prior to 1.0.
fixes #3480
Diffstat (limited to 'lib/sqlalchemy/ext/declarative/api.py')
-rw-r--r-- | lib/sqlalchemy/ext/declarative/api.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/declarative/api.py b/lib/sqlalchemy/ext/declarative/api.py index 3d46bd4cb..dfc47ce95 100644 --- a/lib/sqlalchemy/ext/declarative/api.py +++ b/lib/sqlalchemy/ext/declarative/api.py @@ -7,7 +7,7 @@ """Public API functions and helpers for declarative.""" -from ...schema import Table, MetaData +from ...schema import Table, MetaData, Column from ...orm import synonym as _orm_synonym, \ comparable_property,\ interfaces, properties, attributes @@ -525,6 +525,17 @@ class AbstractConcreteBase(ConcreteBase): mappers.append(mn) pjoin = cls._create_polymorphic_union(mappers) + # For columns that were declared on the class, these + # are normally ignored with the "__no_table__" mapping, + # unless they have a different attribute key vs. col name + # and are in the properties argument. + # In that case, ensure we update the properties entry + # to the correct column from the pjoin target table. + declared_cols = set(to_map.declared_columns) + for k, v in list(to_map.properties.items()): + if v in declared_cols: + to_map.properties[k] = pjoin.c[v.key] + to_map.local_table = pjoin m_args = to_map.mapper_args_fn or dict |