8 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: How to order by a fi...
FromSent OnAttachments
Mart27 Dec 2006 09:41 
Michael Bayer27 Dec 2006 11:26 
Mart28 Dec 2006 03:55 
Michael Bayer28 Dec 2006 08:44 
Michael Bayer28 Dec 2006 08:47 
Mart28 Dec 2006 12:58 
Mart28 Dec 2006 12:58 
Jonathan Ellis06 Jan 2007 22:10 
Subject:[sqlalchemy] Re: How to order by a field in a different table?
From:Mart (roos@gmail.com)
Date:12/28/2006 03:55:52 AM
List:com.googlegroups.sqlalchemy

On Dec 27, 9:26 pm, "Michael Bayer" <zzz@gmail.com> wrote:

if you use eager loading to the relation in question, you can specify its columns in an order by and it will work. such as:

session.query(ParentClass).options(eagerload('childitems')).select(order_by=ChildClass.c.somecol)

I would classify that as a semi-sane version of what I was hoping. And I'd say that it wouldn't be very efficient when dealing with huge amounts of data, so ... Isn't there some way to produce a query like this: SELECT forum_topic.* FROM forum_topic, forum_post WHERE forum_topic.id = forum_post.topic_id GROUP BY forum_topic.id ORDER BY forum_post.created DESC