Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 7efd96844da89219b6fa5a9adfac4e5ff477b833 1 parent 01acd99
@spookylukey spookylukey authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  django/db/models/query.py
  2. +6 −0 tests/modeltests/lookup/models.py
View
2  django/db/models/query.py
@@ -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 {}
View
6 tests/modeltests/lookup/models.py
@@ -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([])
Please sign in to comment.
Something went wrong with that request. Please try again.