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

Update docs to use list_collection_names method #401

Closed
wants to merge 1 commit into from
Closed

Update docs to use list_collection_names method #401

wants to merge 1 commit into from

Conversation

wolfhoundjesse
Copy link

I encountered DeprecationWarning: collection_names is deprecated.

This is a simple name change, but we could also explain the
deprecation in detail in an aside or blockquote.

I encountered DeprecationWarning: collection_names is deprecated.

This is a simple name change, but we could also explain the
deprecation in detail in an aside or blockquote.
@@ -142,7 +142,7 @@ of the collections in our database:

.. doctest::

>>> db.collection_names(include_system_collections=False)
>>> db.list_collection_names(include_system_collections=False)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for finding this issue! It also made me realize that we didn't properly implement the Enumerate Collections Specification. I fixed that by adding support for filter argument in https://jira.mongodb.org/browse/PYTHON-1784.

Can you replace the include_system_collections parameter with a filter that only matches non-system collections, like this:

>>> db.list_collection_names(filter={"name": {"$regex": r"^(?!system\.)"}})
[u'posts']

Copy link
Member

Choose a reason for hiding this comment

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

I just realized that for this doctest it's fine to just remove the include_system_collections=False. We only run the doctests on 4.0+ so we don't need to worry about system collections like (system.indexes) showing up in the results.

ShaneHarvey pushed a commit that referenced this pull request Mar 28, 2019
db.collection_names() is deprecated.
ShaneHarvey pushed a commit that referenced this pull request Mar 28, 2019
db.collection_names() is deprecated.

(cherry picked from commit 66eb6da)
@ShaneHarvey
Copy link
Member

Thanks for the contribution! I merged this to master (66eb6da) and v3.8 (170d217):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants