Skip to content

Incompatibilities with pymongo 4.0 #2598

@bagerard

Description

@bagerard

There is a breaking change in pymongo 4.0 that was released very recently

It fails whenever we save an instance right now

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/local/lib/python3.8/site-packages/mongoengine/document.py:407: in save
    self.ensure_indexes()
/usr/local/lib/python3.8/site-packages/mongoengine/document.py:897: in ensure_indexes
    collection = cls._get_collection()
/usr/local/lib/python3.8/site-packages/mongoengine/document.py:220: in _get_collection
    cls.ensure_indexes()
/usr/local/lib/python3.8/site-packages/mongoengine/document.py:900: in ensure_indexes
    if not collection.is_mongos and collection.read_preference > 1:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = Collection(Database(MongoClient(host=['mongo:27017'], document_class=dict, tz_aware=False, connect=True, read_preference=Primary()), 'cpreview_test'), 'test_document.is_mongos')
    def __bool__(self):
>       raise NotImplementedError("Collection objects do not implement truth "
                                  "value testing or bool(). Please compare "
                                  "with None instead: collection is not None")
E       NotImplementedError: Collection objects do not implement truth value testing or bool(). Please compare with None instead: collection is not None
/usr/local/lib/python3.8/site-packages/pymongo/collection.py:300: NotImplementedError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions