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

Collection should raise an error for non-string collection names

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 5.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Collection.__getitem__ is supposed to only support string names, like this:

      >>> coll = client.db.coll
      >>> coll.name
      'coll'
      >>> coll["foo"].name
      'coll.foo'
      

      However in PYTHON-3084 we discovered that it accidentally supports non-string names as well:

      >>> coll[0].name
      'coll.0'
      >>> coll[{}].name
      'coll.{}'
      

      We should deprecate remove this behavior in PyMongo 5.0.

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

              Created:
              Updated: