you want to use query.join() here, not joinedload. http://www.sqlalchemy.org/trac/wiki/FAQ#ImusinglazyFalsetocreateaJOINOUTERJOINandSQLAlchemyisnotconstructingthequerywhenItrytoaddaWHEREORDERBYLIMITetc.whichreliesupontheOUTERJOIN
I need to update the links in that FAQ entry. On Jan 18, 2011, at 12:12 PM, Alvaro Reinoso wrote: > Hi all, > > It doesn't do the second filter with those queries: > > session.query(User).options(joinedload("channels")).filter(User.id == > int(userId)).filter(Channel.title != > "zeptextstuff.txt").order_by(Channel.titleView).first() > > or > > session.query(User).join(User.channels).filter(User.id == > int(userId)).filter(Channel.title != > "zeptextstuff.txt").order_by(Channel.titleView).first() > > or > > session.query(User).options(joinedload("channels")).filter(and_(User.id > == int(userId), Channel.title != > "zeptextstuff.txt")).order_by(Channel.titleView).first() > > I get a user with a list of sorted channels, but I also get > "zeptextstuff.txt" channel. > > Any clue?? > > Thanks in advance! > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.