Hi:

I apologize if this is covered in a previous post; it's hard to
articulate a search for it!

I have a table that references itself and another table. The
respective models are Work and Owner.
So a Work has a foreign key reference to itself (i.e., to its parent)
and another to Owner. I have the following (some details removed):

    work1 = aliased(Work)
    work2 = aliased(Work)
    query = session.query(work1).outerjoin((work2, work1.parent))
    query = query.outerjoin((Owner, work1.owner))

This results in the following FROM clause:
FROM works AS works_1
LEFT OUTER JOIN works AS works_2 ON works_2.work_id =
works_1.parent_id
LEFT OUTER JOIN owners ON owners.owner_id = works_2.work_owner

Note the second left join is between owners and work2 (ie, works_2
table), but I specified work1 (ie, work1.owner)!

What am I missing?

Ahmed

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