Thanks for the reply. I'll stick with *contains_eager* solution as per your advice. That *bindparam* trick would work in this particular case too but I like flexibility of using former solution.
- alex On Sunday, July 28, 2013 11:50:29 AM UTC-4, Michael Bayer wrote: > > > On Jul 28, 2013, at 9:29 AM, askel <dumm...@mail.ru <javascript:>> 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 . > > -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.