Using q1:
q1 = s.query(Appl).\
distinct(Appl.refid).\
filter(Appl.lastname.ilike('Williamson%')).\
filter(Appl.firstname.ilike('d%')).\
group_by(Appl).\
order_by(Appl.refid, Appl.appldate.desc())
this q2 works as a simple join:
q2 = s.query(q1).\
join(City, City.id==q1.c.cityid).\
order_by(q1.c.lastname, q1.c.firstname)
but there's no relationship mapped to the returned row objects like my "Appl"
class has:
city = relationship('City', lazy='joined', primaryjoin='City.id==Appl.cityid')
I've tried:
c = aliased(City)
q2 = s.query(q1).\
join(Appl.city).\
join(c, Appl.city).\
order_by(q1.c.lastname, q1.c.firstname)
but that returns:
[…]
File
"/Users/nathan/projects/env/lib/python2.7/site-packages/SQLAlchemy-0.8.2-py2.7-macosx-10.8-x86_64.egg/sqlalchemy/orm/mapper.py",
line 1765, in common_parent
return self.base_mapper is other.base_mapper
AttributeError: 'CTE' object has no attribute 'base_mapper'
I need to somehow combine the above 2 "q2" forms to specify both "join(City,
City.id==q1.c.cityid)" and "Appl.city" in join()?
Thanks!
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.