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

GridFS.list() sometimes includes None

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7
    • Affects Version/s: 2.6.3
    • Component/s: None
    • None

      This is surprising. If there's a file in a GridFS collection with no filename, GridFS.list doesn't include None. But after calling get_last_version or get_version, list will include None:

      >>> import pymongo
      >>> import gridfs
      >>> client = pymongo.MongoClient()
      >>> fs = gridfs.GridFS(client.db)
      >>> fs.put(b'hello')
      ObjectId('52882cf5ca1ce99eed9a0524')
      >>> fs.list()
      []
      >>> fs.get_last_version()
      <gridfs.grid_file.GridOut object at 0x1012cb4d0>
      >>> fs.list()
      [None]
      

      This is because get_last_version or get_version ensure an index on (filename, uploadDate). list calls distinct on filename, and the distinct command behaves differently depending on whether it uses an index or not: SERVER-11747.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: