From: Mike Bayer Date: Sun, 24 Jun 2007 18:46:02 +0000 (+0000) Subject: added test for correlation of scalar subqueries to a JOIN object X-Git-Tag: rel_0_3_9~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9dc30f239d1aa13771f0e152af691a8ae56514b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git added test for correlation of scalar subqueries to a JOIN object --- diff --git a/test/sql/select.py b/test/sql/select.py index 37c597a8c8..01fbd5cc85 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -175,6 +175,7 @@ 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( @@ -223,6 +224,12 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A ) self.runtest(q, "SELECT places.id, places.nm, main_zip.zipcode, latlondist((SELECT zips.latitude FROM zips WHERE zips.zipcode = main_zip.zipcode), (SELECT zips.longitude FROM zips WHERE zips.zipcode = main_zip.zipcode)) AS dist FROM places, zips AS main_zip ORDER BY dist, places.nm") + a1 = table2.alias('t2alias') + s1 = select([a1.c.otherid], table1.c.myid==a1.c.otherid, scalar=True) + j1 = table1.join(table2, table1.c.myid==table2.c.otherid) + s2 = select([table1, s1], from_obj=[j1]) + self.runtest(s2, "SELECT mytable.myid, mytable.name, mytable.description, (SELECT t2alias.otherid FROM myothertable AS t2alias WHERE mytable.myid = t2alias.otherid) FROM mytable JOIN myothertable ON mytable.myid = myothertable.otherid") + def testlabelcomparison(self): x = func.lala(table1.c.myid).label('foo') self.runtest(select([x], x==5), "SELECT lala(mytable.myid) AS foo FROM mytable WHERE lala(mytable.myid) = :literal")