diff options
author | Paul Johnston <paj@pajhome.org.uk> | 2007-10-12 20:08:54 +0000 |
---|---|---|
committer | Paul Johnston <paj@pajhome.org.uk> | 2007-10-12 20:08:54 +0000 |
commit | 2821adc57ca46c9310ded691729843a124ddca92 (patch) | |
tree | b4141565c1c50f87731e6b7f860b7ce5a53c8252 | |
parent | 833503ed2327c32937b3feffdf08e520c488fa4c (diff) | |
download | sqlalchemy-2821adc57ca46c9310ded691729843a124ddca92.tar.gz |
Fix broken update/delete queries on MSSQL when tables have a schema
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 748c5d9be..7f539b42d 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -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: diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 572955806..05c7a5cf4 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -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) |