[sqlalchemy] Re: Mapping special child rows

2007-01-12 Thread Jonathan Ellis
Okay, I have another question related to this. Now that I have max_order defined, I want to do a query on it (give me the users whose max_order==5). My code is max_orders_by_user = select([func.max(orders.c.order_id).label('order_id')], group_by=[orders.c.user_id]).alias('max_orders_by_user')

[sqlalchemy] Re: Mapping special child rows

2007-01-12 Thread Michael Bayer
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,

[sqlalchemy] Re: Mapping special child rows

2007-01-08 Thread Michael Bayer
Jonathan Ellis wrote: o2 = orders.select().alias('o2') max_orders = orders.select(orders.c.order_id==max_order_id).alias('max_orders') youre not really showing me what you did there fully so its hard for me to tell how you got that result. - I take it SA doesn't really support subselects

[sqlalchemy] Re: Mapping special child rows

2007-01-08 Thread Michael Bayer
Jonathan Ellis wrote: Hmm, another undocumented option... :) How is a viewonly relation on the class different from a relation on a non_primary mapper? oh theyre both documented. a non_primary mapper means, you load instances from the DB using an alternate table/selectable. once those