summaryrefslogtreecommitdiff
path: root/django/db/models/sql/where.py
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-03-08 03:37:47 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-03-08 03:37:47 +0000
commitfd5d0cdebbc4e6dd620809c21b97bbb822d60b6d (patch)
treeb9f259f3fc85d35eda2bbc74308973c0cdc9130a /django/db/models/sql/where.py
parent84b890b66e80bcc1834c22b8b347641b2e51f455 (diff)
[1.0.X] Fixed #10432 -- Handle all kinds of iterators in queryset filters.
Only consumes the iterators once and works with Python 2.3. Backport of r9986 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9987 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/where.py')
-rw-r--r--django/db/models/sql/where.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 662d99a4a2..277ccef4f2 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -43,6 +43,10 @@ class WhereNode(tree.Node):
return
alias, col, field, lookup_type, value = data
+ if hasattr(value, '__iter__') and hasattr(value, 'next'):
+ # Consume any generators immediately, so that we can determine
+ # emptiness and transform any non-empty values correctly.
+ value = list(value)
try:
if field:
params = field.get_db_prep_lookup(lookup_type, value)