summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_selectable.py25
-rw-r--r--test/sql/test_text.py14
2 files changed, 39 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index dbd73a836..9617cfdf7 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -388,6 +388,31 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
assert u.corresponding_column(s2.c.table2_coly) is u.c.coly
assert s2.corresponding_column(u.c.coly) is s2.c.table2_coly
+ def test_union_of_alias(self):
+ s1 = select([table1.c.col1, table1.c.col2])
+ s2 = select([table1.c.col1, table1.c.col2]).alias()
+
+ u1 = union(s1, s2)
+ assert u1.corresponding_column(s1.c.col1) is u1.c.col1
+ assert u1.corresponding_column(s2.c.col1) is u1.c.col1
+
+ u2 = union(s2, s1)
+ assert u2.corresponding_column(s1.c.col1) is u2.c.col1
+ assert u2.corresponding_column(s2.c.col1) is u2.c.col1
+
+ def test_union_of_text(self):
+ s1 = select([table1.c.col1, table1.c.col2])
+ s2 = text("select col1, col2 from foo").columns(
+ column('col1'), column('col2'))
+
+ u1 = union(s1, s2)
+ assert u1.corresponding_column(s1.c.col1) is u1.c.col1
+ assert u1.corresponding_column(s2.c.col1) is u1.c.col1
+
+ u2 = union(s2, s1)
+ assert u2.corresponding_column(s1.c.col1) is u2.c.col1
+ assert u2.corresponding_column(s2.c.col1) is u2.c.col1
+
def test_select_union(self):
# like testaliasunion, but off a Select off the union.
diff --git a/test/sql/test_text.py b/test/sql/test_text.py
index 57dadfb16..ef63f9daa 100644
--- a/test/sql/test_text.py
+++ b/test/sql/test_text.py
@@ -322,6 +322,20 @@ class AsFromTest(fixtures.TestBase, AssertsCompiledSQL):
}
)
+ def test_column_collection_ordered(self):
+ t = text("select a, b, c from foo").columns(column('a'),
+ column('b'), column('c'))
+ eq_(t.c.keys(), ['a', 'b', 'c'])
+
+ def test_column_collection_pos_plus_bykey(self):
+ # overlapping positional names + type names
+ t = text("select a, b, c from foo").columns(column('a'),
+ column('b'), b=Integer, c=String)
+ eq_(t.c.keys(), ['a', 'b', 'c'])
+ eq_(t.c.b.type._type_affinity, Integer)
+ eq_(t.c.c.type._type_affinity, String)
+
+
def _xy_table_fixture(self):
m = MetaData()
t = Table('t', m, Column('x', Integer), Column('y', Integer))