summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-12-28 00:27:58 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-12-28 00:27:58 +0000
commit5369b3df8c67ee357fd919e5f5d164e55a87d5be (patch)
treec4a84d253030e2baa676cccbd383238b1394da23 /test/sql
parent8d81a40589b22e121c61644ff79847726176bc1e (diff)
downloadsqlalchemy-5369b3df8c67ee357fd919e5f5d164e55a87d5be.tar.gz
- fix to correlation of subqueries when the column list of the select statement
is constructed with individual calls to append_column(); this fixes an ORM bug whereby nested select statements were not getting correlated with the main select generated by the Query object.
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/select.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py
index c422c63fb..5d91276e2 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -149,6 +149,14 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
select([users, s.c.street], from_obj=[s]),
"""SELECT users.user_id, users.user_name, users.password, s.street FROM users, (SELECT addresses.street AS street FROM addresses WHERE addresses.user_id = users.user_id) AS s""")
+ # test constructing the outer query via append_column(), which occurs in the ORM's Query object
+ s = select([], exists([1], table2.c.otherid==table1.c.myid), from_obj=[table1])
+ s.append_column(table1)
+ self.runtest(
+ s,
+ "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE EXISTS (SELECT 1 FROM myothertable WHERE myothertable.otherid = mytable.myid)"
+ )
+
def testcolumnsubquery(self):
s = select([table1.c.myid], scalar=True, correlate=False)
self.runtest(select([table1, s]), "SELECT mytable.myid, mytable.name, mytable.description, (SELECT mytable.myid AS myid FROM mytable) FROM mytable")