On Monday, April 3, 2017 at 7:09:41 PM UTC-4, Jason T. wrote: > > I think there may be even a cleaner way to do this since I have > relationships() built into the models, >
In that case, you will need to use "contains_eager" if you play on iterating on any of the relationships http://docs.sqlalchemy.org/en/latest/orm/loading_relationships.html#using-contains-eager-to-load-a-custom-filtered-collection-result you can also write the above with one filter instead of 3: filter(sam.Branch.ckt == ckt, sam.Branch.id_model == case.id, or_(and_(bus1_alias.number == bus1, bus2_alias.number == bus2), and_(bus1_alias.number == bus2, bus2_alias.number == bus1)) ) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.