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

4.0 migration guide for list_collection_names with include_system_collections is incorrect

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers

      The 4.0 migration guide for list_collection_names with include_system_collections is incorrect:

      Code like
      this::
      
          names = client.collection_names()
          non_system_names = client.collection_names(include_system_collections=False)
      
      can be changed to this::
      
          names = client.list_collection_names()
          non_system_names = client.list_collection_names(filter={"name": {"$regex": r"^(?!system\\.)"}})
      

      Running the above shows it does not actually filter out system collections:

      >>> client.db.list_collection_names(filter={"name": {"$regex": r"^(?!system\\.)"}})
      ['coll', 'system.views', 'time', 'system.buckets.time', 'view']
      

      Also the example is mistakenly calling methods on client when it should be calling them on Database:

      >>> client.list_collection_names(filter={"name": {"$regex": r"^(?!system\\.)"}})
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: 'Database' object is not callable\ 
      

            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: