From 260c201f656ce3afe35f9ae069cdf46593d4dffb Mon Sep 17 00:00:00 2001 From: Michael Trier Date: Wed, 12 Nov 2008 05:36:45 +0000 Subject: Corrected mssql schema named subqueries from not properly aliasing the columns. Fixes #973. --- lib/sqlalchemy/databases/mssql.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/databases') diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index a313b98bc..d806492c6 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -1001,7 +1001,8 @@ class MSSQLCompiler(compiler.DefaultCompiler): return super(MSSQLCompiler, self).visit_alias(alias, **kwargs) def visit_column(self, column, result_map=None, **kwargs): - if column.table is not None and not self.isupdate and not self.isdelete: + if column.table is not None and \ + (not self.isupdate and not self.isdelete) or self.is_subquery(): # translate for schema-qualified table aliases t = self._schema_aliased_table(column.table) if t is not None: @@ -1009,9 +1010,9 @@ class MSSQLCompiler(compiler.DefaultCompiler): if result_map is not None: result_map[column.name.lower()] = (column.name, (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): -- cgit v1.2.1