From 7efd96844da89219b6fa5a9adfac4e5ff477b833 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Sat, 19 Dec 2009 14:50:41 +0000 Subject: [PATCH] Fixed #12251 - QuerySet.in_bulk() should accept set/frozenset Thanks to emulbreh for patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11915 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/query.py | 2 +- tests/modeltests/lookup/models.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/django/db/models/query.py b/django/db/models/query.py index 9cc7659c69..ab85bdc348 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -386,7 +386,7 @@ class QuerySet(object): """ assert self.query.can_filter(), \ "Cannot use 'limit' or 'offset' with in_bulk" - assert isinstance(id_list, (tuple, list)), \ + assert isinstance(id_list, (tuple, list, set, frozenset)), \ "in_bulk() must be provided with a list of IDs." if not id_list: return {} diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py index 94c16ff071..e1973e8456 100644 --- a/tests/modeltests/lookup/models.py +++ b/tests/modeltests/lookup/models.py @@ -102,6 +102,12 @@ Article 4 >>> Article.objects.in_bulk([3]) {3: } +>>> Article.objects.in_bulk(set([3])) +{3: } +>>> Article.objects.in_bulk(frozenset([3])) +{3: } +>>> Article.objects.in_bulk((3,)) +{3: } >>> Article.objects.in_bulk([1000]) {} >>> Article.objects.in_bulk([])