On May 7, 2008, at 1:52 PM, David Gardner wrote:

>
> I've got a small problem, I want to be able to join two related tables
> in a query (in my case JobInfo->Chunk->Pass) so that I could use the
> second table in my order_by(), I would also like them to be  
> eagerloaded.
> The problem is that in the resulting SQL the tables are joined twice,
> once for the order, and once for the eagerload. The code I have is:
>
> ----
> jobs_running = session.query(JobInfo).\
>               outerjoin(['Chunk',
> 'Pass']).options(eagerload_all('Chunk.Pass')).\
>               order_by(JobInfo.c.job_name, Pass.c.name,
> JobInfo.c.owner).all()
> ----

try this:

sess.query(JobInfo).outerjoin(['Chunk',  
'Pass']).options(contains_eager('Chunk'),  
contains_eager('Chunk.Pass')).order_by(...).all()



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to