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

Undocumented regression in Collection.find - projection tuple no longer allowed

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.0.3
    • Affects Version/s: None
    • Component/s: None
    • None

      On PyMongo 2.8.1, a tuple (and maybe other sequences) were allowed as the parameter to the projection. On PyMongo 3, anything but list and dict seems to raise an error:

      $ python -c "__import__('pymongo').MongoClient().test.tests.find(filter=('foo',))"
      $ easy_install -q -U pymongo
      $ python -c "__import__('pymongo').MongoClient().test.tests.find(filter=('foo',))"
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pymongo-3.0.2-py3.4-macosx-10.6-intel.egg/pymongo/collection.py", line 929, in find
          return Cursor(self, *args, **kwargs)
        File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pymongo-3.0.2-py3.4-macosx-10.6-intel.egg/pymongo/cursor.py", line 119, in __init__
          validate_is_mapping("filter", spec)
        File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pymongo-3.0.2-py3.4-macosx-10.6-intel.egg/pymongo/common.py", line 348, in validate_is_mapping
          "collections.Mapping" % (option,))
      TypeError: filter must be an instance of dict, bson.son.SON, or other type that inherits from collections.Mapping
      

      I suggest that the more lenient form be restored including support of any sequence for the projection field names.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            jason.coombs@yougov.com Jason R. Coombs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: