]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add coverage for result map rewriting
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 5 Jun 2013 01:36:34 +0000 (21:36 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 5 Jun 2013 01:36:34 +0000 (21:36 -0400)
- fix the result map rewriter for col mismatches, since the rewritten
select at the moment typically has more columns than the original

lib/sqlalchemy/sql/compiler.py
test/sql/test_join_rewriting.py

index af70d13facae73be248b781b885ec2982a5217ad..c29b4545033a91d3b4e3061f7a0d420183669da7 100644 (file)
@@ -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)
index 701d2588793e7694fe5466623318f504aba0ae29..5a9bdd1d3004483bddb50a0ca384d3c0cb1c429f 100644 (file)
@@ -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)