errr, the relations that mapper setup can feed into select_by would include all the attributes you have on "Order", which does not include "max_order_id". youve got two relations that both point to an "Order" relation, so select_by is more or less out at that point since it can only be given "order_id", and it will just pick one or the other.
however, you might get away with it if you do it like this: mapper(User, users, properties={ 'orders':relation(class_mapper(Order), backref='user'), 'max_order':relation(mapper(Order, max_orders, non_primary=True, properties={'max_order_id':synonym('order_id')}), uselist=False), 'addresses':relation(mapper(Address, addresses), backref='user'), }) session.query(User).select_by(max_order_id=10) just a guess. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---