summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-12-19 10:57:54 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-12-19 10:57:54 +0000
commit519178154be44da2ece9ee9609a0217008616454 (patch)
tree668d2ef6f315daf03781b28f54a9c0da5041a0bf /django/db/models/sql
parent97091940b1efbc6018133e9f77402c2983fa702f (diff)
queryset-refactor: Fixed a problem when adding certain additional filters to a queryset that has precisely one filter attached already.
Refs #6154. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6957 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 2f37e04a01..147c7970ed 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -792,6 +792,11 @@ class Query(object):
q_object.add_to_query(self)
return
+ if self.where and q_object.connector != AND and len(q_object) > 1:
+ self.where.start_subtree(AND)
+ subtree = True
+ else:
+ subtree = False
for child in q_object.children:
if isinstance(child, Node):
self.where.start_subtree(q_object.connector)
@@ -799,6 +804,8 @@ class Query(object):
self.where.end_subtree()
else:
self.add_filter(child, q_object.connector, q_object.negated)
+ if subtree:
+ self.where.end_subtree()
def setup_joins(self, names, opts, alias, dupe_multis):
"""