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
This commit is contained in:
parent
471c9aee97
commit
15295a852f
|
@ -413,8 +413,6 @@ class QuerySet(object):
|
||||||
"""
|
"""
|
||||||
assert self.query.can_filter(), \
|
assert self.query.can_filter(), \
|
||||||
"Cannot use 'limit' or 'offset' with in_bulk"
|
"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:
|
if not id_list:
|
||||||
return {}
|
return {}
|
||||||
qs = self._clone()
|
qs = self._clone()
|
||||||
|
|
|
@ -115,7 +115,8 @@ class LookupTests(TestCase):
|
||||||
self.assertEqual(Article.objects.in_bulk((self.a3.id,)), {self.a3.id: self.a3})
|
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([1000]), {})
|
||||||
self.assertEqual(Article.objects.in_bulk([]), {})
|
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)
|
||||||
self.assertRaises(TypeError, Article.objects.in_bulk, headline__startswith='Blah')
|
self.assertRaises(TypeError, Article.objects.in_bulk, headline__startswith='Blah')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue