]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix broken update/delete queries on MSSQL when tables have a schema
authorPaul Johnston <paj@pajhome.org.uk>
Fri, 12 Oct 2007 20:08:54 +0000 (20:08 +0000)
committerPaul Johnston <paj@pajhome.org.uk>
Fri, 12 Oct 2007 20:08:54 +0000 (20:08 +0000)
lib/sqlalchemy/databases/mssql.py
lib/sqlalchemy/sql/compiler.py

index 748c5d9be1d9c516c831101100dd98161d8ca102..7f539b42da257d99bc69cc0b1c53e585da47b2b1 100644 (file)
@@ -896,7 +896,7 @@ class MSSQLCompiler(compiler.DefaultCompiler):
         return super(MSSQLCompiler, self).visit_alias(alias, **kwargs)
 
     def visit_column(self, column):
-        if column.table is not None:
+        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:
index 572955806a803d6f5a323df3ff5a03a40857072e..05c7a5cf413f3ec689963f1bf00ebe9a0db5aacd 100644 (file)
@@ -104,8 +104,8 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor):
         
         super(DefaultCompiler, self).__init__(dialect, statement, column_keys, **kwargs)
 
-        # if we are insert/update.  set to true when we visit an INSERT or UPDATE
-        self.isinsert = self.isupdate = False
+        # if we are insert/update/delete.  set to true when we visit an INSERT, UPDATE or DELETE
+        self.isdelete = self.isinsert = self.isupdate = False
         
         # compile INSERT/UPDATE defaults/sequences inlined (no pre-execute)
         self.inline = inline or getattr(statement, 'inline', False)
@@ -705,6 +705,7 @@ class DefaultCompiler(engine.Compiled, visitors.ClauseVisitor):
 
     def visit_delete(self, delete_stmt):
         self.stack.append({'from':util.Set([delete_stmt.table])})
+        self.isdelete = True
 
         text = "DELETE FROM " + self.preparer.format_table(delete_stmt.table)