[sqlalchemy] Change relationship order_by on runtime

2011-10-25 Thread neurino
I need to change a collection order_by when a parent instance mapped attribute changes. Something like this: parents = Table('parents', metadata, Column('id', Integer, primary_key=True) Column('reverse', Boolean, primary_key=True) ) items =

Re: [sqlalchemy] Change relationship order_by on runtime

2011-10-25 Thread Michael Bayer
you can use a dynamic relationship which allows you to say: some_parent.items.order_by(items.c.id.desc()) http://www.sqlalchemy.org/docs/orm/collections.html#dynamic-relationship-loaders On Oct 25, 2011, at 5:02 AM, neurino wrote: I need to change a collection order_by when a parent instance

Re: [sqlalchemy] Change relationship order_by on runtime

2011-10-25 Thread neurino
Thank you very much On Tue, Oct 25, 2011 at 3:46 PM, Michael Bayer mike...@zzzcomputing.comwrote: you can use a dynamic relationship which allows you to say: some_parent.items.order_by(items.c.id.desc()) http://www.sqlalchemy.org/docs/orm/collections.html#dynamic-relationship-loaders On