in_bulk should use duck typing so that listy-objects can be used, like ValuesListQuerySet
|Reported by:||umbrae@…||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.3|
|Severity:||Normal||Keywords:||queryset, valueslistqueryset, db|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, using a ValuesListQuerySet as a parameter to in_bulk returns an exception, even with flat=True:
AssertionError: in_bulk() must be provided with a list of IDs.
This is due to this line in query.py (line 416 in 1.3) :
assert isinstance(id_list, (tuple, list, set, frozenset)), \ "in_bulk() must be provided with a list of IDs.
Which requires a certain type, rather than just something that can be iterated upon. I think it'd be more valuable if it was just something iterable, like ValuesListQuerySet is.