I assumed it was a bug due to the presence of a python-style string substitution.
... > another option is > sess.query(Account).filter(Account.id.in_(your subquery)). When I do it that way, I get crazy SQL and an error. Using Account.accountid to shorten the SQL: >>> q0 = >>> s.query(Account.accountid).join(Account.users).group_by(Account.accountid).having(sa.func.count(User.userid)>1).subquery() >>> print sess.query(Account).filter(Account.accountid.in_(q0)) SELECT account.accountid AS account_accountid FROM account, (SELECT account.accountid AS accountid FROM account JOIN users ON account.accountid = users.accountid GROUP BY account.accountid HAVING count(users.userid) > %(count_1)s) AS anon_1 WHERE account.accountid IN SELECT account.accountid FROM account JOIN users ON account.accountid = users.accountid GROUP BY account.accountid HAVING count(users.userid) > %(count_1)s >>> What am I doing wrong? -- Jon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---