summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-10 19:17:00 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-10 19:17:00 -0500
commitbf934018a52b4fe4c43745f88b66210d6517338f (patch)
tree9625b311276be3ac16dfb81e88a63b5714418db1 /test/sql/test_selectable.py
parent7d56f6c8077a3d9aeae3aed2cc548ca4e350161b (diff)
downloadsqlalchemy-bf934018a52b4fe4c43745f88b66210d6517338f.tar.gz
- for TextAsFrom, put the "inner" columns in the result map directly.
Have also considered linking column.label() to the "column" itself being in the result map but this reveals some naming collision problems (that also seem to be very poorly tested...). This should be as far as we want to go right now with [ticket:2932].
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 3c29d9784..dbd73a836 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -1927,6 +1927,75 @@ class WithLabelsTest(fixtures.TestBase):
)
self._assert_result_keys(sel, ['t1_a', 't2_b'])
+class SelectProxyTest(fixtures.TestBase):
+ def _fixture(self):
+ m = MetaData()
+ t = Table('t', m, Column('x', Integer), Column('y', Integer))
+ return t
+
+ def _mapping(self, stmt):
+ compiled = stmt.compile()
+ return dict(
+ (elem, key)
+ for key, elements in compiled.result_map.items()
+ for elem in elements[1]
+ )
+
+ def test_select_label_alt_name(self):
+ t = self._fixture()
+ l1, l2 = t.c.x.label('a'), t.c.y.label('b')
+ s = select([l1, l2])
+ mapping = self._mapping(s)
+ assert l1 in mapping
+
+ assert t.c.x not in mapping
+
+ def test_select_alias_label_alt_name(self):
+ t = self._fixture()
+ l1, l2 = t.c.x.label('a'), t.c.y.label('b')
+ s = select([l1, l2]).alias()
+ mapping = self._mapping(s)
+ assert l1 in mapping
+
+ assert t.c.x not in mapping
+
+ def test_select_alias_column(self):
+ t = self._fixture()
+ x, y = t.c.x, t.c.y
+ s = select([x, y]).alias()
+ mapping = self._mapping(s)
+
+ assert t.c.x in mapping
+
+ def test_select_alias_column_apply_labels(self):
+ t = self._fixture()
+ x, y = t.c.x, t.c.y
+ s = select([x, y]).apply_labels().alias()
+ mapping = self._mapping(s)
+ assert t.c.x in mapping
+
+ def test_select_table_alias_column(self):
+ t = self._fixture()
+ x, y = t.c.x, t.c.y
+
+ ta = t.alias()
+ s = select([ta.c.x, ta.c.y])
+ mapping = self._mapping(s)
+ assert x not in mapping
+
+ def test_select_label_alt_name_table_alias_column(self):
+ t = self._fixture()
+ x, y = t.c.x, t.c.y
+
+ ta = t.alias()
+ l1, l2 = ta.c.x.label('a'), ta.c.y.label('b')
+
+ s = select([l1, l2])
+ mapping = self._mapping(s)
+ assert x not in mapping
+ assert l1 in mapping
+ assert ta.c.x not in mapping
+
class ForUpdateTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = "default"