From: Mike Bayer Date: Wed, 5 Jun 2013 01:36:34 +0000 (-0400) Subject: - add coverage for result map rewriting X-Git-Tag: rel_0_9_0b1~294^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=69e9574fefd5fbb4673c99ad476a00b03fe22318;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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 --- diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index af70d13fac..c29b454503 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 701d258879..5a9bdd1d30 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)