diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-23 14:49:04 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-23 14:49:04 -0500 |
| commit | 15b23c7f71c0ca8c526db2794b2c459c84875ab3 (patch) | |
| tree | 7f793ff00fdbd81ca0b6acaf4437e7e09ee9f087 /lib/sqlalchemy | |
| parent | 9fef2c314bef31758e878d03d7793e744f2562c6 (diff) | |
| download | sqlalchemy-15b23c7f71c0ca8c526db2794b2c459c84875ab3.tar.gz | |
- Fixed an 0.9 regression where the automatic aliasing applied by
:class:`.Query` and in other situations where selects or joins
were aliased (such as joined table inheritance) could fail if a
user-defined :class:`.Column` subclass were used in the expression.
In this case, the subclass would fail to propagate ORM-specific
"annotations" along needed by the adaptation. The "expression
annotations" system has been corrected to account for this case.
[ticket:2918]
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 1 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/annotation.py | 13 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 6bd465e9c..23fe9315a 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -229,7 +229,6 @@ class Query(object): have been applied within this query.""" adapters = [] - # do we adapt all expression elements or only those # tagged as 'ORM' constructs ? orm_only = getattr(self, '_orm_only_adapt', orm_only) diff --git a/lib/sqlalchemy/sql/annotation.py b/lib/sqlalchemy/sql/annotation.py index b5b7849d2..11b066675 100644 --- a/lib/sqlalchemy/sql/annotation.py +++ b/lib/sqlalchemy/sql/annotation.py @@ -167,9 +167,18 @@ def _new_annotation_type(cls, base_cls): return cls elif cls in annotated_classes: return annotated_classes[cls] + + for super_ in cls.__mro__: + # check if an Annotated subclass more specific than + # the given base_cls is already registered, such + # as AnnotatedColumnElement. + if super_ in annotated_classes: + base_cls = annotated_classes[super_] + break + annotated_classes[cls] = anno_cls = type( - "Annotated%s" % cls.__name__, - (base_cls, cls), {}) + "Annotated%s" % cls.__name__, + (base_cls, cls), {}) globals()["Annotated%s" % cls.__name__] = anno_cls return anno_cls |
