Given the User-Addresses schema as in the docs, I need to select all users along with only those email addresses which end with "@gmail.com". The question is how do I group these filtered emails by user? Apparently I can use `contains_eager` to write something like this:
session.query(User).outerjoin(User.addresses).filter(Address.email_address.like('%@gmail.com'))\ .options(contains_eager(User.addresses)) But having the filtered email addresses on the `addresses` attribute is rather confusing. I'd like to either: 1. iterate a query results in a clear way: for user, gmail_addrs in session.query(???) 2. get the filtered children attached to a different field (smth like `contains_eager(User.addresses, attach_to='_gmail_addrs')`) Thanks. -- 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/d/optout.