summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index a4c3ddf40..8f599f1d6 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -26,6 +26,11 @@ table2 = Table('table2', metadata,
Column('coly', Integer),
)
+keyed = Table('keyed', metadata,
+ Column('x', Integer, key='colx'),
+ Column('y', Integer, key='coly'),
+ Column('z', Integer),
+)
class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
__dialect__ = 'default'
@@ -91,6 +96,24 @@ class SelectableTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
assert sel3.corresponding_column(l1) is sel3.c.foo
assert sel3.corresponding_column(l2) is sel3.c.bar
+ def test_keyed_gen(self):
+ s = select([keyed])
+ eq_(s.c.colx.key, 'colx')
+
+ # this would change to 'colx'
+ # with #2397
+ eq_(s.c.colx.name, 'x')
+
+ assert s.corresponding_column(keyed.c.colx) is s.c.colx
+ assert s.corresponding_column(keyed.c.coly) is s.c.coly
+ assert s.corresponding_column(keyed.c.z) is s.c.z
+
+ sel2 = s.alias()
+ assert sel2.corresponding_column(keyed.c.colx) is sel2.c.colx
+ assert sel2.corresponding_column(keyed.c.coly) is sel2.c.coly
+ assert sel2.corresponding_column(keyed.c.z) is sel2.c.z
+
+
def test_distance_on_aliases(self):
a1 = table1.alias('a1')
for s in (select([a1, table1], use_labels=True),