Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1784

Database.list_collection_names should accept a filter argument

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.8
    • Affects Version/s: None
    • Component/s: None
    • None

      According to theĀ Enumerate Collections Spec, both list_collections and list_collection_names "MUST allow a filter to be passed to include only requested collections".

      I noticed this while reviewing https://github.com/mongodb/mongo-python-driver/pull/401. In this PR, we would like to change this line in the docs to use the new list_collection_names:

      >>> db.collection_names(include_system_collections=False)
      [u'posts']
      

      However, db.list_collection_names() will not have the same behavior because it will include system collections. According to the spec we should support this:

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

      Supporting "filter" will also aid users who are migrating from collection_names to list_collection_names.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: