Tried that still no luck. If it helps any, the job_info table is 
temporary and doesn't have any keys, or foreign keys, since it is being 
constantly updated. So I am doing the join in my mapper:

qstat_mapper = mapper(JobInfo, qstat_table, 
primary_key=[qstat_table.c.job_number], properties={
                      'Chunk':relation(Chunk, lazy=True, uselist=False,
                       
primaryjoin=chunk_table.c.queue_job_id==qstat_table.c.job_number,
                       foreign_keys=[chunk_table.c.queue_job_id])})

Michael Bayer wrote:
> 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()
>
>
>
> >
>
>   


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