with eagerload/lazyload, you should treat them as the same, meaning, when you say mapper.select(), the things asked for in the eager loads have nothing to do with your select. treat the relationships as though they arent there. if you look at the generated SQL, eagerloading uses aliases to keep the joins from having anything to do with wahtever query you asked for. in this particular case, im not sure exactly where youre person.firstname is winding up in the query, id have to see the SQL its generating, but seems like at least its not really getting used in the query.
so you are really looking for, making some assumptions about your table relations: orders = list(self.order_mapper.select( and_( Order.c.person_id==Person.c.person_id, Person.c.firstname.like('%foo%') ) )) Koen Bok wrote: > I don't exactly understand how to search within the relations of a > mapper object. It seems that whatever the search string is for a > child object, the mapper always returns every object. > > Example: > > order_mapper = Order.mapper.options( > eagerload('person'), > eagerload('orderproducts'), > eagerload('orderproducts.product')) > > orders = list(self.order_mapper.select( > Person.c.firstname.like('%foo%'))) > > I get every order object returned this way, while I would expect to > only see the objects returned with foo in their person's firstname. ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users