Mike Bayer  committed dc460ca

some fixes to the MS-SQL aliasing so that result_map is properly populated

  • Participants
  • Parent commits bcfe447

Comments (0)

Files changed (2)

File lib/sqlalchemy/databases/

         kwargs['mssql_aliased'] = True
         return super(MSSQLCompiler, self).visit_alias(alias, **kwargs)
-    def visit_column(self, column, **kwargs):
+    def visit_column(self, column, result_map=None, **kwargs):
         if column.table is not None and not self.isupdate and not self.isdelete:
             # translate for schema-qualified table aliases
             t = self._schema_aliased_table(column.table)
             if t is not None:
-                return self.process(expression._corresponding_column_or_error(t, column))
-        return super(MSSQLCompiler, self).visit_column(column, **kwargs)
+                converted = expression._corresponding_column_or_error(t, column)
+                if result_map is not None:
+                    result_map[] = (, (column, ), column.type)
+                return super(MSSQLCompiler, self).visit_column(converted, result_map=None, **kwargs)
+        return super(MSSQLCompiler, self).visit_column(column, result_map=result_map, **kwargs)
     def visit_binary(self, binary, **kwargs):
         """Move bind parameters to the right-hand side of an operator, where possible."""

File test/dialect/

             schema = 'remote_owner'
+        s =
+        c = s.compile(dialect=self.__dialect__)
+        assert table4.c.rem_id in set(c.result_map['rem_id'][1])
+        s =
+        c = s.compile(dialect=self.__dialect__)
+        print c.result_map
+        assert table4.c.rem_id in set(c.result_map['remote_owner_remotetable_rem_id'][1])
         self.assert_compile(, "SELECT remotetable_1.rem_id, remotetable_1.datatype_id, remotetable_1.value FROM remote_owner.remotetable AS remotetable_1")
+        self.assert_compile(, "SELECT remotetable_1.rem_id AS remote_owner_remotetable_rem_id, remotetable_1.datatype_id AS remote_owner_remotetable_datatype_id, remotetable_1.value AS remote_owner_remotetable_value FROM remote_owner.remotetable AS remotetable_1")
         self.assert_compile(table1.join(table4, table1.c.myid==table4.c.rem_id).select(), "SELECT mytable.myid,, mytable.description, remotetable_1.rem_id, remotetable_1.datatype_id, remotetable_1.value FROM mytable JOIN remote_owner.remotetable AS remotetable_1 ON remotetable_1.rem_id = mytable.myid")