Skip to content

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

Merged
bagerard merged 3 commits into
MongoEngine:masterfrom
026Fatih:master
Aug 30, 2026
Merged

Fix: Handle collection.objects when it's a partial function#2889
bagerard merged 3 commits into
MongoEngine:masterfrom
026Fatih:master

Conversation

@026Fatih

Copy link
Copy Markdown
Contributor

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

@bagerard

bagerard commented Sep 2, 2025

Copy link
Copy Markdown
Collaborator

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

@026Fatih

026Fatih commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

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.

@bagerard bagerard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, I did some mnor adjustment on top as there was a simpler fix (https://github.com/MongoEngine/mongoengine/pull/2932/changes)

@bagerard
bagerard merged commit eb36a3a into MongoEngine:master Aug 30, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants