mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Fix: Handle collection.objects when it's a partial function

Open 026Fatih opened this issue 8 months ago • 2 comments

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).

026Fatih avatar Jul 25 '25 19:07 026Fatih

Hi, could you clarify in which case collection.objects is a partial and provide a test case ?

bagerard avatar Sep 02 '25 18:09 bagerard

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.

026Fatih avatar Sep 03 '25 23:09 026Fatih