summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-08-07 20:58:23 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-08-07 20:58:23 -0400
commitcbb0a03a560fd33933971e7b4c9293918612a2cf (patch)
tree11d1941cf09de593ef4e4c0ae31aebc7a28ce1e7 /test/sql/test_selectable.py
parent9d6cb72791502e7a704a244093d6daca9697dd3c (diff)
downloadsqlalchemy-cbb0a03a560fd33933971e7b4c9293918612a2cf.tar.gz
- the _Label construct, i.e. the one that is produced
whenever you say somecol.label(), now counts itself in its "proxy_set" unioned with that of it's contained column's proxy set, instead of directly returning that of the contained column. This allows column correspondence operations which depend on the identity of the _Labels themselves to return the correct result - fixes ORM bug [ticket:1852].
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 062ed5f1b..5bebbe05f 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -28,20 +28,40 @@ table2 = Table('table2', metadata,
class SelectableTest(TestBase, AssertsExecutionResults):
- def test_distance_on_labels(self):
-
+ def test_indirect_correspondence_on_labels(self):
+ # this test depends upon 'distance' to
+ # get the right result
+
# same column three times
s = select([table1.c.col1.label('c2'), table1.c.col1,
table1.c.col1.label('c1')])
- # didnt do this yet...col.label().make_proxy() has same
- # "distance" as col.make_proxy() so far assert
- # s.corresponding_column(table1.c.col1) is s.c.col1
+ # this tests the same thing as
+ # test_direct_correspondence_on_labels below -
+ # that the presence of label() affects the 'distance'
+ assert s.corresponding_column(table1.c.col1) is s.c.col1
assert s.corresponding_column(s.c.col1) is s.c.col1
assert s.corresponding_column(s.c.c1) is s.c.c1
+ def test_direct_correspondence_on_labels(self):
+ # this test depends on labels being part
+ # of the proxy set to get the right result
+
+ l1, l2 = table1.c.col1.label('foo'), table1.c.col1.label('bar')
+ sel = select([l1, l2])
+
+ sel2 = sel.alias()
+ assert sel2.corresponding_column(l1) is sel2.c.foo
+ assert sel2.corresponding_column(l2) is sel2.c.bar
+
+ sel2 = select([table1.c.col1.label('foo'), table1.c.col2.label('bar')])
+
+ sel3 = sel.union(sel2).alias()
+ assert sel3.corresponding_column(l1) is sel3.c.foo
+ assert sel3.corresponding_column(l2) is sel3.c.bar
+
def test_distance_on_aliases(self):
a1 = table1.alias('a1')
for s in (select([a1, table1], use_labels=True),