diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-12-03 21:10:55 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-12-03 21:10:55 +0000 |
| commit | 8e6126fbc2ebbda6d14a888dbe16cfe3b64339bf (patch) | |
| tree | 68954ded181cdf04d84fe13a4c9b1d182957f992 /django | |
| parent | 57a4b882aeddc6f171d25808c8510bd09c410eff (diff) | |
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
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/sql/where.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index 28a4a80abb..97e6c38e6b 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -42,6 +42,7 @@ class WhereNode(tree.Node): return None, [] result = [] result_params = [] + empty = True for child in node.children: if hasattr(child, 'as_sql'): sql, params = child.as_sql(qn=qn) @@ -60,10 +61,15 @@ class WhereNode(tree.Node): if self.connector == AND and not node.negated: # We can bail out early in this particular case (only). raise - sql = None + elif node.negated: + empty = False + continue + empty = False if sql: result.append(format % sql) result_params.extend(params) + if empty: + raise EmptyResultSet conn = ' %s ' % node.connector return conn.join(result), result_params |
