summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-02-24 00:17:08 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-02-24 00:17:08 +0000
commit41802e102cf1436930f43d1ec19005bcceb41691 (patch)
treed7b7e1f77685f4e553fcb70ce725417b3672cb3c /test/sql
parent736bc3bd5194a9a9f9dbb2424e4c0b6139bc8a77 (diff)
downloadsqlalchemy-41802e102cf1436930f43d1ec19005bcceb41691.tar.gz
- correlated subqueries work inside of ORDER BY, GROUP BY
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/select.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/test/sql/select.py b/test/sql/select.py
index 7473d4f63..14a5009f1 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -162,6 +162,17 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A
s,
"SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE EXISTS (SELECT 1 FROM myothertable WHERE myothertable.otherid = mytable.myid)"
)
+
+ def testorderbysubquery(self):
+ self.runtest(
+ table1.select(order_by=[select([table2.c.otherid], table1.c.myid==table2.c.otherid)]),
+ "SELECT mytable.myid, mytable.name, mytable.description FROM mytable ORDER BY (SELECT myothertable.otherid AS otherid FROM myothertable WHERE mytable.myid = myothertable.otherid)"
+ )
+ self.runtest(
+ table1.select(order_by=[desc(select([table2.c.otherid], table1.c.myid==table2.c.otherid))]),
+ "SELECT mytable.myid, mytable.name, mytable.description FROM mytable ORDER BY (SELECT myothertable.otherid AS otherid FROM myothertable WHERE mytable.myid = myothertable.otherid) DESC"
+ )
+
def testcolumnsubquery(self):
s = select([table1.c.myid], scalar=True, correlate=False)
@@ -566,15 +577,17 @@ myothertable.othername != :myothertable_othername AND EXISTS (select yay from fo
self.runtest(query.select(), "SELECT mytable.myid, mytable.name, mytable.description, myothertable.otherid, myothertable.othername, thirdtable.userid, thirdtable.otherstuff FROM mytable, myothertable, thirdtable WHERE mytable.myid = myothertable.otherid(+) AND thirdtable.userid(+) = myothertable.otherid", dialect=oracle.dialect(use_ansi=False))
def testbindparam(self):
- self.runtest(select(
+ for stmt, assertion in [
+ (
+ select(
[table1, table2],
and_(table1.c.myid == table2.c.otherid,
- table1.c.name == bindparam('mytablename'),
- )
- ),
+ table1.c.name == bindparam('mytablename')),
"SELECT mytable.myid, mytable.name, mytable.description, myothertable.otherid, myothertable.othername \
-FROM mytable, myothertable WHERE mytable.myid = myothertable.otherid AND mytable.name = :mytablename"
- )
+ FROM mytable, myothertable WHERE mytable.myid = myothertable.otherid AND mytable.name = :mytablename"
+ )
+ ]:
+ self.runtest(stmt, assertion)
# check that the bind params sent along with a compile() call
# get preserved when the params are retreived later