Re: [sqlalchemy] Dynamic relationship in queries

2013-07-28 Thread askel
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:

Re: [sqlalchemy] Dynamic relationship in queries

2013-07-28 Thread Michael Bayer
On Jul 28, 2013, at 9:29 AM, askel 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 give

[sqlalchemy] Dynamic relationship in queries

2013-07-28 Thread askel
Hello everybody, I've been tearing my hairs out trying to figure out how to achieve the following. Base = declarative_base() class Group(Base): g_id = Column(Integer, primary_key=True) events = relationship('Event', backref='group', lazy='dynamic') class Event(Base