Michael,

On 27/01/2010 19:37, Michael Bayer wrote:
werner wrote:
q2 = session.query(stAlias2).outerjoin((stAlias2,
stAlias2.code_id==stAlias3.code_id),
this is going to render

select * from<alias2>  left outer join<alias2>  on
<alias2>.code_id==<alias3>.code_id

i.e. renders<alias2>  twice in the FROM


Thanks for the pointer.

It took me a long time to figure out the "onclause" for this but this is what I ended up with and it works for me.

stAlias1 = db.sao.aliased(db.Somecode_T)
q1 = session.query(stAlias1).filter(stAlias1.lang_code5=='FR_fr')

stAlias2 = db.sao.aliased(db.Somecode_T)
stAlias3 = db.sao.aliased(db.Somecode_T)

q2 = session.query(stAlias2).outerjoin((stAlias3, db.sa.and_(
                            stAlias2.code_id == stAlias3.code_id,
stAlias3.lang_code5 == 'FR_fr'))).filter(db.sa.and_(
                                stAlias2.lang_code5 == 'EN_en',
                                stAlias3.id == db.sa.null()))

q3 = q1.union(q2)

Thanks
Werner

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