Author: phd
Date: 2007-04-20 07:58:02 -0600 (Fri, 20 Apr 2007)
New Revision: 2574
Modified:
home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
home/phd/SQLObject/paramstyles/sqlobject/tests/test_joins_conditional.py
Log:
Merged patches from the revisions 2570:2572 from the trunk
Modified: home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2007-04-20 13:47:52 UTC (rev 2573)
+++ home/phd/SQLObject/paramstyles/sqlobject/dbconnection.py 2007-04-20 13:58:02 UTC (rev 2574)
@@ -487,17 +487,21 @@
if type(join) is str:
join_str = ' ' + join
elif isinstance(join, sqlbuilder.SQLJoin):
- if tables and join.table1:
+ if join.table1:
join_str = ", "
else:
join_str = ' '
join_str += self.sqlrepr(join)
else:
- if tables and join[0].table1:
- join_str = ", "
- else:
- join_str = ' '
- join_str += " ".join([self.sqlrepr(j) for j in join])
+ join_str = ""
+ for j in join:
+ if j.table1:
+ sep = ", "
+ else:
+ sep = ' '
+ join_str += sep + self.sqlrepr(j)
+ if not tables and join_str.startswith(','):
+ join_str = join_str[1:].strip()
return join_str
def _addWhereClause(self, select, startSelect, limit=1, order=1):
Modified: home/phd/SQLObject/paramstyles/sqlobject/tests/test_joins_conditional.py
===================================================================
--- home/phd/SQLObject/paramstyles/sqlobject/tests/test_joins_conditional.py 2007-04-20 13:47:52 UTC (rev 2573)
+++ home/phd/SQLObject/paramstyles/sqlobject/tests/test_joins_conditional.py 2007-04-20 13:58:02 UTC (rev 2574)
@@ -35,7 +35,7 @@
on_condition=(TestJoin1.q.col1 == TestJoin2.q.col2))
)
assert str(select) == \
- "SELECT test_join1.id, test_join1.col1 FROM test_join1 LEFT JOIN test_join2 ON ((test_join1.col1) = (test_join2.col2)) WHERE 1 = 1"
+ "SELECT test_join1.id, test_join1.col1 FROM test_join1 LEFT JOIN test_join2 ON ((test_join1.col1) = (test_join2.col2)) WHERE 1 = 1"
def test_3perform_join():
setup()
@@ -70,6 +70,12 @@
assert str(select) == \
"SELECT test_join1.id, test_join1.col1 FROM test_join1 LEFT JOIN test_join2 LEFT JOIN test_join3 WHERE 1 = 1"
+ select = TestJoin1.select(
+ join=(LEFTJOIN(TestJoin1, TestJoin2), LEFTJOIN(TestJoin1, TestJoin3))
+ )
+ assert str(select) == \
+ "SELECT test_join1.id, test_join1.col1 FROM test_join1 LEFT JOIN test_join2, test_join1 LEFT JOIN test_join3 WHERE 1 = 1"
+
def test_6join_using():
setup()
setupClass(TestJoin3)
|