From 15295a852f181d8812fd06aef2763b28443bc331 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 26 Mar 2011 17:50:10 +0000 Subject: [PATCH] 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 --- django/db/models/query.py | 2 -- tests/modeltests/lookup/tests.py | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/django/db/models/query.py b/django/db/models/query.py index 324554eb78..0fc48f8a41 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -413,8 +413,6 @@ class QuerySet(object): """ 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() diff --git a/tests/modeltests/lookup/tests.py b/tests/modeltests/lookup/tests.py index cf18a83945..3f40bf10f5 100644 --- a/tests/modeltests/lookup/tests.py +++ b/tests/modeltests/lookup/tests.py @@ -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([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')