diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-01-06 12:25:17 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-01-06 12:25:17 -0500 |
| commit | 9f3b42cbce9db3592961b375dd14f6701a37f7cf (patch) | |
| tree | 82600bc8696a215d11269c7d8618860ed608b7d1 /lib/sqlalchemy/orm | |
| parent | e46301b5154000148155ef00d15b35857ebb31ad (diff) | |
| download | sqlalchemy-9f3b42cbce9db3592961b375dd14f6701a37f7cf.tar.gz | |
- Fixed bug regarding "subqueryload" strategy whereby
the join would fail if using a multi-level load
of the form from A->joined-subclass->C [ticket:2014]
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 7d3e563f4..333650ec4 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -746,9 +746,23 @@ class SubqueryLoader(AbstractRelationshipLoader): for i in xrange(0, len(subq_path), 2) ] + # determine the immediate parent class we are joining from, + # which needs to be aliased. + if len(to_join) < 2: + # in the case of a one level eager load, this is the + # leftmost "left_alias". parent_alias = left_alias + elif subq_path[-2].isa(self.parent): + # In the case of multiple levels, retrieve + # it from subq_path[-2]. This is the same as self.parent + # in the vast majority of cases, and [ticket:2014] + # illustrates a case where sub_path[-2] is a subclass + # of self.parent + parent_alias = mapperutil.AliasedClass(subq_path[-2]) else: + # if of_type() were used leading to this relationship, + # self.parent is more specific than subq_path[-2] parent_alias = mapperutil.AliasedClass(self.parent) local_cols, remote_cols = \ |
