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
This commit is contained in:
Luke Plant 2009-12-19 14:50:41 +00:00
parent 01acd99947
commit 7efd96844d
2 changed files with 7 additions and 1 deletions

View File

@ -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 {}

View File

@ -102,6 +102,12 @@ Article 4
<Article: Article 2>
>>> Article.objects.in_bulk([3])
{3: <Article: Article 3>}
>>> Article.objects.in_bulk(set([3]))
{3: <Article: Article 3>}
>>> Article.objects.in_bulk(frozenset([3]))
{3: <Article: Article 3>}
>>> Article.objects.in_bulk((3,))
{3: <Article: Article 3>}
>>> Article.objects.in_bulk([1000])
{}
>>> Article.objects.in_bulk([])