summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-06-06 13:35:33 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-06-06 13:35:33 +0000
commit151d88af4e972547c40f1e70a3cd982f202f5c86 (patch)
treedb0a29fc314bcb765e587e8f482f3d9c16ba327a /django/db/models/sql/query.py
parentfa43a32bcbfd7b2e7092c664251406416ef280fd (diff)
Fixed #11082 -- Ensured that subqueries used in an exclude(X__in=) clause aren't pre-evaluated. Thanks to Henry Andrews for the report, and clement for the fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10929 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 15b9fd6366..23f99e41ad 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1625,10 +1625,14 @@ class BaseQuery(object):
entry.negate()
self.where.add(entry, AND)
break
- elif not (lookup_type == 'in' and not value) and field.null:
+ elif not (lookup_type == 'in'
+ and not hasattr(value, 'as_sql')
+ and not hasattr(value, '_as_sql')
+ and not value) and field.null:
# Leaky abstraction artifact: We have to specifically
# exclude the "foo__in=[]" case from this handling, because
# 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.negate()