diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-04 21:36:34 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-04 21:36:34 -0400 |
commit | 69e9574fefd5fbb4673c99ad476a00b03fe22318 (patch) | |
tree | 5e02b7f3ead639e242bc3fb65c52dbea95fb9e6d | |
parent | ae2561a7d1495d0d542571ae65b4ce1377eddf00 (diff) | |
download | sqlalchemy-69e9574fefd5fbb4673c99ad476a00b03fe22318.tar.gz |
- add coverage for result map rewriting
- fix the result map rewriter for col mismatches, since the rewritten
select at the moment typically has more columns than the original
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 7 | ||||
-rw-r--r-- | test/sql/test_join_rewriting.py | 6 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index af70d13fa..c29b45450 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1151,7 +1151,12 @@ class SQLCompiler(engine.Compiled): return visit(select) def _transform_result_map_for_nested_joins(self, select, transformed_select): - d = dict(zip(transformed_select.inner_columns, select.inner_columns)) + inner_col = dict((c._key_label, c) for + c in transformed_select.inner_columns) + d = dict( + (inner_col[c._key_label], c) + for c in select.inner_columns + ) for key, (name, objs, typ) in list(self.result_map.items()): objs = tuple([d.get(col, col) for col in objs]) self.result_map[key] = (name, objs, typ) diff --git a/test/sql/test_join_rewriting.py b/test/sql/test_join_rewriting.py index 701d25887..5a9bdd1d3 100644 --- a/test/sql/test_join_rewriting.py +++ b/test/sql/test_join_rewriting.py @@ -37,6 +37,12 @@ class _JoinRewriteTestBase(AssertsCompiledSQL): assert_ ) + compiled = s.compile(dialect=self.__dialect__) + for key, col in zip([c.key for c in s.c], s.inner_columns): + key = key % compiled.anon_map + assert col in compiled.result_map[key][1] + + def test_a_bc(self): j1 = b.join(c) j2 = a.join(j1) |