There are two reasonable options for this, one is to select tuples of group, user, task and join them together with appropriate conditions:
session.query(Group, User, Task).outerjoin(Group.users).outerjoin ((Task, (Task.user_id == User.id) & ~Task.complete)) the other option is to create a new relation on User that encapsulates the derived relation to incomplete tasks: mapper(User, users_tbl, properties=dict( incomplete_tasks = relation(Task, viewonly=True, primaryjoin= (users_tbl.c.id == tasks_tbl.c.user_id) & ~tasks_tbl.c.complete) )) now you can eagerload that collection: session.query(Group).options(eagerload_all('users.incomplete_tasks')) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---