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

Write concern not honored on collection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5
    • Affects Version/s: 2.4.1, 2.4.2
    • Component/s: None
    • None

      As safe=True is deprecated in favor of write concern, we updated our code to support the write_concern parameter. In one place, we set safe=True on the collection:

      coll = db[collection_name]
      coll.safe = True
      coll.update(...)
      

      If I update our code to use write concern, however, the equivalent code fails. Here's a script demonstrating the issue:

      from __future__ import print_function
      import pymongo
      db = pymongo.Connection().test
      coll = db.mycoll
      coll.write_concern.update(w=1)
      coll.insert({'y': 3})
      res = coll.update({'y': 3}, {'x': 3})
      print("first res is", res)
      coll.safe=True
      res = coll.update({'x': 3}, {'w': 3})
      print("second res is", res)
      
      """
      output is
      first res is None
      second res is {u'updatedExisting': True, u'connectionId': 2, u'ok': 1.0, u'err': None, u'n': 1}
      """
      

      Is this an unintended regression? Are we using an unsupported API? Is there a supported way to set the write concern at the collection level, such as we currently can with the (deprecated) 'safe' property?

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            jason.coombs@yougov.com Jason R. Coombs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: