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

Inconsistent handling of safe=False

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • 2.2
    • 2.3
    • None
    • None
    • Minor Change

    Description

      >>> from pymongo import Connection
      >>> from bson.objectid import ObjectId
      >>> c = Connection(safe=True)
      >>> c.test.foo.insert({'_id':1})
      1
      >>> c.test.foo.insert({'_id':1}, safe=False)

      Expected: no error, because 'safe' is False

      Actual: DuplicateKeyError.

      update() and insert() can be expected to override the collection's, database's, and connection's 'safe' setting same as for 'w' and other getLastError options, but don't for safe=False; only for safe=True.

      Also, at least in Python 2.7.1,

      Connection(wtimeout=1000, safe=False).safe

      is False, but should be True. The final value of 'safe' when a Connection, Database, or Collection is given safe=False and getLastError options is unpredictable.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: