Collection should raise an error for non-string collection names

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • 5.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
              Reporter:
              Shane Harvey
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: