diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-24 13:19:34 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-24 13:19:34 -0400 |
| commit | 9c68542116285c94bc2584edcd25fec6cf305eba (patch) | |
| tree | 03a9249d35693a60d3faf1059b650a35458e5b75 /lib/sqlalchemy | |
| parent | 4a794aa5481b3d6e6ab3bae6d12c39d8cb228da8 (diff) | |
| download | sqlalchemy-9c68542116285c94bc2584edcd25fec6cf305eba.tar.gz | |
everything everything passes on this one. still want to get rid of that hack tho.
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/orm/strategies.py | 16 |
2 files changed, 5 insertions, 14 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index c56804847..d0827df84 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -1069,7 +1069,8 @@ class Query(object): left = self._joinpoint_zero() if left is right and \ - not create_aliases: + not create_aliases and \ + not self._entity_zero()._subq_aliasing: raise sa_exc.InvalidRequestError( "Can't construct a join from %s to %s, they are the same entity" % (left, right)) diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 92b560cd9..cf1839df7 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -699,8 +699,6 @@ class SubqueryLoader(AbstractRelationshipLoader): # for the significant columns, not order # by anything. q = orig_query._clone() -# q._attributes = {} -# q._attributes[("orig_query", SubqueryLoader)] = orig_query q._set_entities(q._adapt_col_list(leftmost_attr)) if q._limit is None and q._offset is None: q._order_by = None @@ -708,19 +706,15 @@ class SubqueryLoader(AbstractRelationshipLoader): embed_q = q.with_labels().subquery() q = q.session.query(self.mapper) + + # magic hardcody thing. TODO: dammit + q._entities[0]._subq_aliasing = True q._attributes = {} q._attributes[("orig_query", SubqueryLoader)] = orig_query left_alias = mapperutil.AliasedClass(leftmost_mapper, embed_q) q = q.select_from(left_alias) -# q = q.from_self(self.mapper) - - # TODO: this is currently a magic hardcody - # flag on _MapperEntity. we should find - # a way to turn it into public functionality. -# q._entities[0]._subq_aliasing = True - q._attributes[('subquery_path', None)] = subq_path to_join = [ @@ -729,10 +723,6 @@ class SubqueryLoader(AbstractRelationshipLoader): ] if len(to_join) < 2: -# local_attr = [ -# self.parent._get_col_to_prop(c).class_attribute -# for c in local_cols -# ] local_attr = [ getattr(left_alias, self.parent._get_col_to_prop(c).key) for c in local_cols |
