]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added test for correlation of scalar subqueries to a JOIN object
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 24 Jun 2007 18:46:02 +0000 (18:46 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 24 Jun 2007 18:46:02 +0000 (18:46 +0000)
test/sql/select.py

index 37c597a8c8a889942cb7a1f28c5d1dccf4495641..01fbd5cc851ac60a1e4b4317ea32da644baa8c90 100644 (file)
@@ -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")