I having problems trying to create a query with to left joins as only one
allows having the left table specified, the rest have to be None,
otherwise it generates invalid SQL.
I'm trying to do, more or less:
SELECT t1.*
FROM t1,
t2 LEFT JOIN s2
ON t2.f = t2.f, # <- sqlobject does not add this comma
t3 LEFT JOIN s3
ON t3.g = t2.g
WHERE ....
I don't know how to do it, looking in the doc and tests it looks like I
should do it like this:
where2 = ....
leftjoin2 = LEFTJOINOn(t2, s2, where2)
where3 = ....
leftjoin3 = LEFTJOINOn(t3, s3, where3)
where = ....
final_select = t1.select(where, join=(leftjoin2, leftjoin3))
This generates the previuos query but without the comma between the two
joins. That's why it works if I don't specify the first table in the
second join, because thn the SQL is corrrect as it would left join the
first specified table in the query, t1 in this case:
where2 = ....
leftjoin2 = LEFTJOINOn(t2, s2, where2)
where3 = ....
leftjoin3 = LEFTJOINOn(None, s3, where3)
where = ....
final_select = t1.select(where, join=(leftjoin2, leftjoin3))
This creates a valid query:
SELECT t1.*
FROM t1,
t2 LEFT JOIN s2
ON t2.f = t2.f # <- we don't need this comma now, so it's ok.
LEFT JOIN s3
ON t3.g = t2.g
WHERE ....
Can anybody tell me how to do it? I've tested the latest svn and it does
not work.
Thanks
Pau
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss