Search code examples
mongodbpymongomongoengine

pymongo 4.1.1 and mongoengine version compatibility


Updated to pymongo 4.1.1 and upgraded mongoengine to 0.24.1 but received the following error:

pymongo/collection.py", line 1610, in find
    return Cursor(self, *args, **kwargs)
TypeError: __init__() got an unexpected keyword 
argument 'modifiers'

I was under the impression the latest versions would work together. Are they not compatible? The error appears in pymongo itself and not in my code.


Solution

  • This pymongo error seems to come from a removed option.

    From the pymongo API docs:

    Changed in version 4.0: Removed the modifiers option. Empty projections (eg {} or []) are passed to the server as-is, rather than the previous behavior which substituted in a projection of {"_id": 1}. This means that an empty projection will now return the entire document, not just the "_id" field.

    In addition, currently (2022-05-04) there seem to be several pymongo >= 4.0 issues against the mongoengine codebase.