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

Improve error message when attempting to insert document using insert_many

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • None
    • None

    Description

      When a user accidentally/incorrectly attempts to insert a single document using insert_many as follows:

      client.database.collection.insert_many({'_id': 1, 'data': 'foo})
      

      PyMongo returns the following error message:

      TypeError: document must be an instance of dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a type that inherits from collections.MutableMapping
      

      We should consider making the error message easier to understand in this situation by augmenting the validation we perform here to check that the user has not passed an instance of abc.MutableMapping

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              prashant.mital Prashant Mital (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: