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

Collection should raise an error for non-string collection names

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Backlog
    • Unknown
    • Resolution: Unresolved
    • None
    • 5.0
    • None
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated: