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

Improve error message when attempting to insert document using insert_many

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      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

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

              Created:
              Updated:
              Resolved: