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

Inconsistent handling of safe=False

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.3
    • Affects Version/s: 2.2
    • Component/s: None
    • None
    • Minor Change

      >>> 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.

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

              Created:
              Updated:
              Resolved: