summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-12-09 23:27:04 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-12-09 23:27:04 +0000
commit5cdb942791b9aeb63d02680c712d1afc104606b0 (patch)
treeb4a0d319063136e299bf4a01399febc767c10186 /test/sql
parent7cbfbba9496fc41c21390aad8d8731c45fbacbce (diff)
downloadsqlalchemy-5cdb942791b9aeb63d02680c712d1afc104606b0.tar.gz
- Query.select_from() now replaces all existing FROM criterion with
the given argument; the previous behavior of constructing a list of FROM clauses was generally not useful as is required filter() calls to create join criterion, and new tables introduced within filter() already add themselves to the FROM clause. The new behavior allows not just joins from the main table, but select statements as well. Filter criterion, order bys, eager load clauses will be "aliased" against the given statement.
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/select.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py
index 626dc3847..10e92a083 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -128,6 +128,21 @@ sq2.sq_myothertable_otherid, sq2.sq_myothertable_othername FROM \
sq.mytable_description AS sq_mytable_description, sq.myothertable_otherid AS sq_myothertable_otherid, \
sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") AS sq) AS sq2")
+ def test_nested_uselabels(self):
+ """test nested anonymous label generation. this
+ essentially tests the ANONYMOUS_LABEL regex.
+ """
+
+ s1 = table1.select()
+ s2 = s1.alias()
+ s3 = select([s2], use_labels=True)
+ s4 = s3.alias()
+ s5 = select([s4], use_labels=True)
+ self.assert_compile(s5, "SELECT anon_1.anon_2_myid AS anon_1_anon_2_myid, anon_1.anon_2_name AS anon_1_anon_2_name, "\
+ "anon_1.anon_2_description AS anon_1_anon_2_description FROM (SELECT anon_2.myid AS anon_2_myid, anon_2.name AS anon_2_name, "\
+ "anon_2.description AS anon_2_description FROM (SELECT mytable.myid AS myid, mytable.name AS name, mytable.description "\
+ "AS description FROM mytable) AS anon_2) AS anon_1")
+
def testmssql_noorderbyinsubquery(self):
"""test that the ms-sql dialect removes ORDER BY clauses from subqueries"""
dialect = mssql.dialect()