- changed milestone to 0.6.9
_ColumnEntity selectable needs to be consistent with its mapper zero
Issue #2197
resolved
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class Locality(Base):
Id = Column( Integer, primary_key = True, autoincrement = True)
__tablename__ = 'locality'
name = Column( String(128), nullable = False)
class Street(Base):
Id = Column(Integer, primary_key = True)
__tablename__ = 'street'
name = Column( String(128), nullable = False)
localityId = Column(Integer, ForeignKey(Locality.Id))
locality = orm.relation(Locality, primaryjoin = localityId == Locality.Id)
session.query(Locality.name + ' ' + Street.name).join(Street.locality)
# vs
session.query(Street.name + ' ' + Locality.name).join(Street.locality)
# in one case, the ent.selectable is used, in the other, fallback to "left".
# ent.selectable needs to be consistent with mapper_zero on _ColumnElement
patch:
diff -r e30d02c6259d5a2386fd836e27dee75e3a143bd2 lib/sqlalchemy/orm/query.py
--- a/lib/sqlalchemy/orm/query.py Thu Jun 16 12:09:45 2011 -0400
+++ b/lib/sqlalchemy/orm/query.py Mon Jun 20 10:33:17 2011 -0400
@@ -2845,7 +2845,8 @@
def setup_entity(self, entity, mapper, adapter, from_obj,
is_aliased_class, with_polymorphic):
- self.selectable = from_obj
+ if 'selectable' not in self.__dict__:
+ self.selectable = from_obj
self.froms.add(from_obj)
def corresponds_to(self, entity):
test should include:
- the above joins
- a variety of _ColumnElement ensure that selectable matches to mapper_zero, try to get aliasing in there
Comments (3)
-
reporter -
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.6.9 (automated comment)
- Log in to comment