diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-06-05 21:23:11 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-06-05 21:23:11 +0000 |
| commit | 698a3c1ac665e7cd2ef8d5ad3ebf51b7fe6661f4 (patch) | |
| tree | f7c4f623bcb1f8df537b08ada140d6ba44edec64 /lib | |
| parent | 31b95e6cdce83e14cd1c462c2b7d16a0f8652d19 (diff) | |
| download | sqlalchemy-698a3c1ac665e7cd2ef8d5ad3ebf51b7fe6661f4.tar.gz | |
- Fixed Query being able to join() from individual columns of
a joined-table subclass entity, i.e.
query(SubClass.foo, SubcClass.bar).join(<anything>).
In most cases, an error "Could not find a FROM clause to join
from" would be raised. In a few others, the result would be
returned in terms of the base class rather than the subclass -
so applications which relied on this erroneous result need to be
adjusted. [ticket:1431]
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index e3cc3c756..dee57bbc1 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -899,7 +899,7 @@ class Query(object): # after the method completes, # the query's joinpoint will be set to this. right_entity = None - + for arg1 in util.to_list(keys): aliased_entity = False alias_criterion = False @@ -969,6 +969,10 @@ class Query(object): clause = ent.selectable break + # TODO: + # this provides one kind of "backwards join" + # tested in test/orm/query.py. + # remove this in 0.6 if not clause: if isinstance(onclause, interfaces.PropComparator): clause = onclause.__clause_element__() @@ -2057,11 +2061,8 @@ class _ColumnEntity(_QueryEntity): if _is_aliased_class(entity): return entity is self.entity_zero else: - # TODO: this will fail with inheritance, entity_zero - # is not a base mapper. MapperEntity has path_entity - # which serves this purpose (when saying: query(FooBar.somecol).join(SomeClass, FooBar.id==SomeClass.foo_id)) - return entity.base_mapper is self.entity_zero - + return not _is_aliased_class(self.entity_zero) and entity.base_mapper.common_parent(self.entity_zero) + def _resolve_expr_against_query_aliases(self, query, expr, context): return query._adapt_clause(expr, False, True) |
