On Jul 28, 2013, at 9:29 AM, askel <dummy...@mail.ru> wrote: > What I have ended up with is the following: > > class Group(Base): > events = relationship('Event', lazy=True) > > session.query(Group).join(Group.events).options(contains_eager(Group.events).filter(Event.e_date=='2013-01-01') > > The above gives me what I want and does not look crazy. It might be using > undocumented side effect of contains_eager option though.
that is exactly the effect of contains_eager(), it means, "my query loads the collection as I want, please populate it". I'd stick with that approach. But also there is a recipe for bound parameters in primaryjoin, that's at http://www.sqlalchemy.org/trac/wiki/UsageRecipes/GlobalFilter .
signature.asc
Description: Message signed with OpenPGP using GPGMail