diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2011-03-26 17:50:10 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2011-03-26 17:50:10 +0000 |
| commit | 15295a852f181d8812fd06aef2763b28443bc331 (patch) | |
| tree | 6026b510dd073530003e2eb2a77d87a83b16c771 | |
| parent | 471c9aee9771da32b942e71c7dcaef97a4c70f1c (diff) | |
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
| -rw-r--r-- | django/db/models/query.py | 2 | ||||
| -rw-r--r-- | 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') |
