mongoengine
mongoengine copied to clipboard
Fix: Handle collection.objects when it's a partial function
collection.objects can be a partial function. When it is, trying to call in_bulk on it was causing error.
Note: I added explicit type check before calling it, but I can change it to be always called (because query set is callable).
Hi, could you clarify in which case collection.objects is a partial and provide a test case ?
Hello,
This issue occurs when the custom queryset manager function takes more than two parameters. In that case, it gets wrapped in a partial, as shown in the snippet from mongoengine/queryset/manager.py:
else:
queryset = partial(self.get_queryset, owner, queryset)
I'll be adding a test case shortly.