From 93d1fdb1304ed5b2e5ea2e0f1e84db7fff5eb7fa Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Mon, 9 Apr 2012 00:43:08 +0000 Subject: Fixed #17877 -- Ensured that extra WHERE clauses get correctly ANDed when they contain OR operations. Thanks to Marek Brzóska for the report, to eleather for the test case and to Adrien Lemaire for the patch. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@17880 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/where.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index 2bd705dd60..0bc3638b80 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -281,7 +281,8 @@ class ExtraWhere(object): self.params = params def as_sql(self, qn=None, connection=None): - return " AND ".join(self.sqls), tuple(self.params or ()) + sqls = ["(%s)" % sql for sql in self.sqls] + return " AND ".join(sqls), tuple(self.params or ()) class Constraint(object): """ -- cgit v1.3