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()
----
which produces:

SELECT <several columns here>
FROM farm.qstatus
LEFT OUTER JOIN farm.chunk ON farm.chunk.queue_job_id = 
farm.qstatus.job_number
LEFT OUTER JOIN farm.pass ON farm.pass.job = farm.chunk.job AND 
farm.pass.name = farm.chunk.pass
LEFT OUTER JOIN farm.chunk AS chunk_1 ON chunk_1.queue_job_id = 
farm.qstatus.job_number
LEFT OUTER JOIN farm.pass AS pass_1 ON pass_1.job = chunk_1.job AND 
pass_1.name = chunk_1.pass
ORDER BY farm.qstatus.job_name, farm.pass.name, farm.qstatus.owner, 
chunk_1.job, pass_1.name


-- 
David Gardner
Pipeline Tools Programmer, "Sid the Science Kid"
Jim Henson Creature Shop
(323) 802-1717 [EMAIL PROTECTED]



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to