Thats it, I just need to use from_statement. OK this works producing 
good SQL:

    statement = 
qstat_table.outerjoin(chunk_table).select(use_labels=True).order_by(JobInfo.c.job_name,
 
Chunk.c.pass_field, JobInfo.c.owner)
    query = 
session.query(JobInfo).options(contains_eager('Chunk')).filter_by(**kwargs)
    r = query.from_statement(statement).all()

Michael Bayer wrote:
> On May 7, 2008, at 6:12 PM, David Gardner wrote:
>
>   
>> Sorry, both contains_eager and eagerload_all() work, however both
>> produce the same SQL, where both related tables are joined twice. They
>> both produce:
>>     
>
> ah, my apologies, I was recommending a usage which has only been added
> in 0.5.  Fortunately its fairly straightforward so I've backported it
> for you in 0.4 in rev 4683.  contains_eager() will disable the normal
> rendering of the LEFT OUTER JOIN so that even with a non-
> from_statement() Query can make effective use of contains_eager().
>
> (note for ltbarcly, this is for you as well)
>
>
> >
>
>   


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