From cd99c62e2de8701ffd940d86da8e41798c10007d Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sun, 8 Mar 2009 03:32:16 +0000 Subject: Fixed #10432 -- Handle all kinds of iterators in queryset filters. Only consumes the iterators once and works with Python 2.3. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9986 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/sql/where.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'django/db/models/sql/where.py') diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index a711103485..ec0545ca5b 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -47,6 +47,10 @@ class WhereNode(tree.Node): return obj, 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) if hasattr(obj, "process"): try: obj, params = obj.process(lookup_type, value) -- cgit v1.3