Skip to content

v2.2.0 list_collection_names Breaking Change #20

@AlecRosenbaum

Description

@AlecRosenbaum

The hasattr call below seems to always pass, meaning that the new function is called even if it doesn't exist (making this a breaking change from 2.1.2 -> 2.2.0):

def list_collection_names(db):
if hasattr(db, 'list_collection_names'):
return db.list_collection_names()
return db.collection_names(include_system_collections=False)

Example (partially omitted for legibility):

>>> db
Database(MongoClient(...), 'mydb')

>>> db.collection_names(include_system_collections=False)
['mycollection', ...]

>>> hasattr(db, 'list_collection_names')
True

>>> db.list_collection_names()
TypeError: 'Collection' object is not callable.

>>> hasattr(db, 'this is a nonsense string')
True

Introduced with 982ad12

I suspect insert_many will have the same issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions