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

Add flag to create_collection to skip listCollections pre-check

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Unknown
    • Resolution: Done
    • None
    • 4.2
    • None

    Description

      Add flag to create_collection to skip listCollections pre-check. For example:

      >>> client.db.create_collection("name")
      Collection(...)
      >>> client.db.create_collection("name")
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/Users/shane/git/mongo-python-driver/pymongo/database.py", line 378, in create_collection
          raise CollectionInvalid("collection %s already exists" % name)
      pymongo.errors.CollectionInvalid: collection name already exists
      >>> client.db.create_collection("name", check_exists=False)
      Collection(...)
      

      Motivation:

      1. spec tests assume that drivers do not call listCollections in the createCollection helper. Our current behavior requires workarounds in the spec runner to ignore the listCollections command.
      2. This gives us a path to change the default createCollection behavior (to check_exists=False) in pymongo 5.0.
      3. I think we made the wrong decision in PYTHON-1936. We should have introduced this option in 3.x and changed the behavior in 4.0.

      Note the name of the flag is TBD, check_exists might end up being the final name but it's only an example.

      Attachments

        Issue Links

          Activity

            People

              julius.park@mongodb.com Julius Park
              shane.harvey@mongodb.com Shane Harvey
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: