Author: phd
Date: 2007-05-02 12:01:17 -0600 (Wed, 02 May 2007)
New Revision: 2625
Modified:
SQLObject/branches/0.8/docs/News.txt
SQLObject/branches/0.8/sqlobject/sqlbuilder.py
SQLObject/branches/0.8/sqlobject/tests/test_aliases.py
Log:
Fixed a bug with Aliases in JOINs.
Modified: SQLObject/branches/0.8/docs/News.txt
===================================================================
--- SQLObject/branches/0.8/docs/News.txt 2007-05-02 18:00:53 UTC (rev 2624)
+++ SQLObject/branches/0.8/docs/News.txt 2007-05-02 18:01:17 UTC (rev 2625)
@@ -150,8 +150,6 @@
Bug Fixes
---------
-* Fixed a minor comparison problem in test_decimal.py.
-
* Fixed a longstanding bug with .select() ignoring 'limit' parameter.
* Fixed a bug with absent comma in JOINs.
@@ -163,8 +161,12 @@
* Fixed a longstanding bug with sqlbuilder.Select() with groupBy being a
sequence.
+* Fixed a bug with Aliases in JOINs.
+
* Yet another patch to properly initialize MySQL connection encoding.
+* Fixed a minor comparison problem in test_decimal.py.
+
* More documentation about orderBy.
SQLObject 0.7.5
Modified: SQLObject/branches/0.8/sqlobject/sqlbuilder.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/sqlbuilder.py 2007-05-02 18:00:53 UTC (rev 2624)
+++ SQLObject/branches/0.8/sqlobject/sqlbuilder.py 2007-05-02 18:01:17 UTC (rev 2625)
@@ -740,12 +740,12 @@
def __init__(self, table1, table2, op=','):
if table1 and type(table1) <> str:
if isinstance(table1, Alias):
- table1 = "%s AS %s" % (table1.q.tableName, table1.q.alias)
+ table1 = "%s %s %s" % (table1.q.tableName, AliasField.as_string, table1.q.alias)
else:
table1 = table1.sqlmeta.table
if type(table2) <> str:
if isinstance(table2, Alias):
- table2 = "%s AS %s" % (table2.q.tableName, table2.q.alias)
+ table2 = "%s %s %s" % (table2.q.tableName, AliasField.as_string, table2.q.alias)
else:
table2 = table2.sqlmeta.table
self.table1 = table1
Modified: SQLObject/branches/0.8/sqlobject/tests/test_aliases.py
===================================================================
--- SQLObject/branches/0.8/sqlobject/tests/test_aliases.py 2007-05-02 18:00:53 UTC (rev 2624)
+++ SQLObject/branches/0.8/sqlobject/tests/test_aliases.py 2007-05-02 18:01:17 UTC (rev 2625)
@@ -25,3 +25,12 @@
alias = Alias(JoinAlias)
select = JoinAlias.select(JoinAlias.q.parent == alias.q.name)
assert select.count() == 2
+
+def test_3joins():
+ setupClass(JoinAlias)
+ alias = Alias(JoinAlias)
+ select = JoinAlias.select((JoinAlias.q.name == 'a') & (alias.q.name == 'b'),
+ join=LEFTJOINOn(None, alias, alias.q.name == 'c')
+ )
+ assert str(select) == \
+ "SELECT join_alias.id, join_alias.name, join_alias.parent FROM join_alias LEFT JOIN join_alias join_alias_alias3 ON ((join_alias_alias3.name) = ('c')) WHERE (((join_alias.name) = ('a')) AND ((join_alias_alias3.name) = ('b')))"
|