From 8a483dbf38168ff43ca0652229b1d46afb23235d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 24 Jul 2011 17:51:01 -0400 Subject: - rewrite cloned_traverse() and replacement_traverse() to use a straight recursive descent with clone() + _copy_internals(). This is essentially what it was doing anyway with lots of unnecessary steps. Fix Alias() to honor the given clone() function which may have been the reason the traversal hadn't been fixed sooner. Alias._copy_internals() will specifically skip an alias of a Table as a more specific form of what it was doing before. This may need to be further improved such that ClauseAdapter or replacement_traverse() send it some specific hints what not to dig into; **kw has been added to all _copy_internals() to support this. replacement/clone traversal is at least clear now. - apply new no_replacement_traverse annotation to join created by _create_joins(), fixes [ticket:2195] - can replace orm.query "_halt_adapt" with "no_replacement_traverse" --- test/sql/test_selectable.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/sql/test_selectable.py') diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index 63be50a97..555271f16 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -914,6 +914,13 @@ class AnnotationsTest(fixtures.TestBase): b5 = visitors.cloned_traverse(b3, {}, {'binary':visit_binary}) assert str(b5) == ":bar = table1.col2" + def test_annotate_aliased(self): + t1 = table('t1', column('c1')) + s = select([(t1.c.c1 + 3).label('bat')]) + a = s.alias() + a = sql_util._deep_annotate(a, {'foo': 'bar'}) + eq_(a._annotations['foo'], 'bar') + eq_(a.element._annotations['foo'], 'bar') def test_annotate_expressions(self): table1 = table('table1', column('col1'), column('col2')) -- cgit v1.2.1