mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +00:00
queryset-refactor: Fixed disjunctions of empty result sets. Refs #6074.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6868 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
57a4b882ae
commit
8e6126fbc2
@ -42,6 +42,7 @@ class WhereNode(tree.Node):
|
|||||||
return None, []
|
return None, []
|
||||||
result = []
|
result = []
|
||||||
result_params = []
|
result_params = []
|
||||||
|
empty = True
|
||||||
for child in node.children:
|
for child in node.children:
|
||||||
if hasattr(child, 'as_sql'):
|
if hasattr(child, 'as_sql'):
|
||||||
sql, params = child.as_sql(qn=qn)
|
sql, params = child.as_sql(qn=qn)
|
||||||
@ -60,10 +61,15 @@ class WhereNode(tree.Node):
|
|||||||
if self.connector == AND and not node.negated:
|
if self.connector == AND and not node.negated:
|
||||||
# We can bail out early in this particular case (only).
|
# We can bail out early in this particular case (only).
|
||||||
raise
|
raise
|
||||||
sql = None
|
elif node.negated:
|
||||||
|
empty = False
|
||||||
|
continue
|
||||||
|
empty = False
|
||||||
if sql:
|
if sql:
|
||||||
result.append(format % sql)
|
result.append(format % sql)
|
||||||
result_params.extend(params)
|
result_params.extend(params)
|
||||||
|
if empty:
|
||||||
|
raise EmptyResultSet
|
||||||
conn = ' %s ' % node.connector
|
conn = ' %s ' % node.connector
|
||||||
return conn.join(result), result_params
|
return conn.join(result), result_params
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user