summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2010-06-21 16:11:17 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2010-06-21 16:11:17 +0000
commit706b18966f7f6dcef715ca7b5230e72147cefda6 (patch)
treeb71751270c449ab0dcfe9123c7eb91e4a770a373 /django/db
parentdd5e71829627705d68905d91fc18c3554a9c69c8 (diff)
[soc2010/query-refactor] Cleaned up implementation of negation in MongoDB, and no longer rely on a feature from MongoDB unstable version.
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13368 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
-rw-r--r--django/db/models/sql/query.py6
-rw-r--r--django/db/models/sql/where.py6
2 files changed, 10 insertions, 2 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 959990f628..6836337429 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1077,7 +1077,11 @@ class Query(object):
# it's short-circuited in the Where class.
# We also need to handle the case where a subquery is provided
entry = self.where_class()
- entry.add((Constraint(alias, col, None), 'isnull', True), AND)
+ entry.add((
+ Constraint(alias, col, None, eliminatable_if=lambda connection: not getattr(connection.features, "sql_nulls", True)),
+ 'isnull',
+ True
+ ), AND)
entry.negate()
self.where.add(entry, AND)
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 4e5a647259..e953bca703 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -267,8 +267,9 @@ class Constraint(object):
An object that can be passed to WhereNode.add() and knows how to
pre-process itself prior to including in the WhereNode.
"""
- def __init__(self, alias, col, field):
+ def __init__(self, alias, col, field, eliminatable_if=None):
self.alias, self.col, self.field = alias, col, field
+ self.elimintable_if = eliminatable_if
def __getstate__(self):
"""Save the state of the Constraint for pickling.
@@ -321,6 +322,9 @@ class Constraint(object):
except ObjectDoesNotExist:
raise EmptyShortCircuit
+ if self.elimintable_if and self.elimintable_if(connection):
+ raise FullResultSet
+
return (self.alias, self.col, db_type), params
def relabel_aliases(self, change_map):