Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.2.0 list_collection_names Breaking Change #20

Open
AlecRosenbaum opened this issue Jul 1, 2020 · 0 comments
Open

v2.2.0 list_collection_names Breaking Change #20

AlecRosenbaum opened this issue Jul 1, 2020 · 0 comments

Comments

@AlecRosenbaum
Copy link

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.

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

No branches or pull requests

1 participant