summaryrefslogtreecommitdiff
path: root/test/sql/test_selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-03-31 13:35:05 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-03-31 13:35:05 -0400
commit45046367f34ee2dadb98024b0f2b05248459f978 (patch)
tree6c13c76762b1d10eb580eb95a6d4cf7840bfb167 /test/sql/test_selectable.py
parentb1fb11dda0454ca9738338e7cc549547c158222b (diff)
downloadsqlalchemy-45046367f34ee2dadb98024b0f2b05248459f978.tar.gz
- [bug] Fixed bug in expression annotation
mechanics which could lead to incorrect rendering of SELECT statements with aliases and joins, particularly when using column_property(). [ticket:2453]
Diffstat (limited to 'test/sql/test_selectable.py')
-rw-r--r--test/sql/test_selectable.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 904819215..7befa8283 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -1134,6 +1134,30 @@ class AnnotationsTest(fixtures.TestBase):
assert b4.left is bin.left # since column is immutable
assert b4.right is not bin.right is not b2.right is not b3.right
+ def test_annotate_unique_traversal(self):
+ """test that items are copied only once during
+ annotate, deannotate traversal"""
+ table1 = table('table1', column('x'))
+ table2 = table('table1', column('y'))
+ a1 = table1.alias()
+ s = select([a1.c.x]).select_from(
+ a1.join(table2, a1.c.x==table2.c.y)
+ )
+
+ for sel in (
+ sql_util._deep_deannotate(s),
+ sql_util._deep_annotate(s, {'foo':'bar'}),
+ visitors.cloned_traverse(s, {}, {}),
+ visitors.replacement_traverse(s, {}, lambda x:None)
+ ):
+ # the columns clause isn't changed at all
+ assert sel._raw_columns[0].table is a1
+ # the from objects are internally consistent,
+ # i.e. the Alias at position 0 is the same
+ # Alias in the Join object in position 1
+ assert sel._froms[0] is sel._froms[1].left
+ eq_(str(s), str(sel))
+
def test_bind_unique_test(self):
t1 = table('t', column('a'), column('b'))