From fd5d0cdebbc4e6dd620809c21b97bbb822d60b6d Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sun, 8 Mar 2009 03:37:47 +0000 Subject: [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 --- django/db/models/sql/where.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'django/db') 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) -- cgit v1.3