- changed status to resolved
try to improve query.join() when dealing with pure SQL expressions
Issue #1522
resolved
at least have it barf more elegantly, perhaps:
class A(Base):
__tablename__ = 'a'
id = Column(Integer, primary_key=True)
data = Column(String)
def __repr__(s):
return '<A id:%s data:%s>' % (s.id, s.data)
class B(Base):
__tablename__ = 'b'
id = Column(Integer, primary_key=True)
data = Column(String)
def __repr__(s):
return '<B id:%s data:%s>' % (s.id, s.data)
with some data:
session.add_all([A(data='a1'),A(data='a2'),B(data='b1'),B(data='b2'),](A(data='a1'),A(data='a2'),B(data='b1'),B(data='b2'),))
session.commit()
and subqueries:
subqa = session.query(A.id, A.data.label('blah')).subquery()
subqb = session.query(B.id, B.data.label('blah')).subquery()
First attempt:
session.query(subqa.c.blah, subqb.c.blah)
as expected this give a cross join of all A's and B's
Second attempt:
session.query(subqa.c.blah, subqb.c.blah).join((subqb,subqb.c.id==subqa.c.id
))
gives and error:
AttributeError: 'NoneType' object has no attribute 'base_mapper'
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: 0.5.6 (automated comment)
- Log in to comment
aa73243fdeabbbbe0390222a96de8454839b5cf3 f7307aabe689f250ac5a8a1fda8d7e11c8545c65