From 55eacc8dbea3c3f98197bde9034fd6558fb2bc09 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 8 May 2014 22:44:06 -0400 Subject: - Fixed bug where :meth:`.Table.update` and :meth:`.Table.delete` would produce an empty WHERE clause when an empty :func:`.and_()` or :func:`.or_()` or other blank expression were applied. This is now consistent with that of :func:`.select`. fixes #3045 --- lib/sqlalchemy/sql/compiler.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index a7465204a..cd01ea5e5 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1839,7 +1839,9 @@ class SQLCompiler(Compiled): text += " " + extra_from_text if update_stmt._whereclause is not None: - text += " WHERE " + self.process(update_stmt._whereclause) + t = self.process(update_stmt._whereclause) + if t: + text += " WHERE " + t limit_clause = self.update_limit_clause(update_stmt) if limit_clause: @@ -2261,8 +2263,9 @@ class SQLCompiler(Compiled): delete_stmt, delete_stmt._returning) if delete_stmt._whereclause is not None: - text += " WHERE " - text += delete_stmt._whereclause._compiler_dispatch(self) + t = delete_stmt._whereclause._compiler_dispatch(self) + if t: + text += " WHERE " + t if self.returning and not self.returning_precedes_values: text += " " + self.returning_clause( -- cgit v1.2.1