summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-03-01 20:14:17 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-03-01 20:14:17 +0000
commit7e2ae824a56c760286e33adce03324b8e696472a (patch)
treee2b0a85db431cf4a7234aa027d2a0453aa615bfd /test/sql
parentd94384253f496be5f8db9745a2cac8fc6c82c69b (diff)
downloadsqlalchemy-7e2ae824a56c760286e33adce03324b8e696472a.tar.gz
- use_labels flag on select() wont auto-create labels for literal text
column elements, since we can make no assumptions about the text. to create labels for literal columns, you can say "somecol AS somelabel", or use literal_column("somecol").label("somelabel") - quoting wont occur for literal columns when they are "proxied" into the column collection for their selectable (is_literal flag is propigated)
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/select.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/sql/select.py b/test/sql/select.py
index a4e863dae..a021bd5b9 100644
--- a/test/sql/select.py
+++ b/test/sql/select.py
@@ -350,6 +350,26 @@ WHERE mytable.myid = myothertable.otherid) AS t2view WHERE t2view.mytable_myid =
select(["column1", "column2"], from_obj=[table1]).alias('somealias').select(),
"SELECT somealias.column1, somealias.column2 FROM (SELECT column1, column2 FROM mytable) AS somealias"
)
+
+ # test that use_labels doesnt interfere with literal columns
+ self.runtest(
+ select(["column1", "column2", table1.c.myid], from_obj=[table1], use_labels=True),
+ "SELECT column1, column2, mytable.myid AS mytable_myid FROM mytable"
+ )
+
+ # test that use_labels doesnt interfere with literal columns that have textual labels
+ self.runtest(
+ select(["column1 AS foobar", "column2 AS hoho", table1.c.myid], from_obj=[table1], use_labels=True),
+ "SELECT column1 AS foobar, column2 AS hoho, mytable.myid AS mytable_myid FROM mytable"
+ )
+
+ # test that "auto-labeling of subquery columns" doesnt interfere with literal columns,
+ # exported columns dont get quoted
+ self.runtest(
+ select(["column1 AS foobar", "column2 AS hoho", table1.c.myid], from_obj=[table1]).select(),
+ "SELECT column1 AS foobar, column2 AS hoho, myid FROM (SELECT column1 AS foobar, column2 AS hoho, mytable.myid AS myid FROM mytable)"
+ )
+
def testtextbinds(self):
self.runtest(
text("select * from foo where lala=:bar and hoho=:whee"),