Skip to content

Commit

Permalink
Fixed #12251 - QuerySet.in_bulk() should accept set/frozenset
Browse files Browse the repository at this point in the history
Thanks to emulbreh for patch.



git-svn-id: http://code.djangoproject.com/svn/django/trunk@11915 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
spookylukey committed Dec 19, 2009
1 parent 01acd99 commit 7efd968
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/db/models/query.py
Expand Up @@ -386,7 +386,7 @@ def in_bulk(self, id_list):
"""
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 {}
Expand Down
6 changes: 6 additions & 0 deletions tests/modeltests/lookup/models.py
Expand Up @@ -102,6 +102,12 @@ def __unicode__(self):
<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([])
Expand Down

0 comments on commit 7efd968

Please sign in to comment.