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

GridFS.list() sometimes includes None

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.6.3
    • 2.7
    • None
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: