Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #15647 -- Changed in_bulk() not to type check its input, which …

…now allows for passing any iterable. Thanks, calvinspealman

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15922 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 15295a852f181d8812fd06aef2763b28443bc331 1 parent 471c9ae
@adrianholovaty adrianholovaty authored
Showing with 2 additions and 3 deletions.
  1. +0 −2  django/db/models/query.py
  2. +2 −1  tests/modeltests/lookup/tests.py
View
2  django/db/models/query.py
@@ -413,8 +413,6 @@ 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, set, frozenset)), \
- "in_bulk() must be provided with a list of IDs."
if not id_list:
return {}
qs = self._clone()
View
3  tests/modeltests/lookup/tests.py
@@ -115,7 +115,8 @@ def test_in_bulk(self):
self.assertEqual(Article.objects.in_bulk((self.a3.id,)), {self.a3.id: self.a3})
self.assertEqual(Article.objects.in_bulk([1000]), {})
self.assertEqual(Article.objects.in_bulk([]), {})
- self.assertRaises(AssertionError, Article.objects.in_bulk, 'foo')
+ self.assertEqual(Article.objects.in_bulk(iter([self.a1.id])), {self.a1.id: self.a1})
+ self.assertEqual(Article.objects.in_bulk(iter([])), {})
self.assertRaises(TypeError, Article.objects.in_bulk)
self.assertRaises(TypeError, Article.objects.in_bulk, headline__startswith='Blah')
Please sign in to comment.
Something went wrong with that request. Please try again.