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

Write concern not honored on collection

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.1, 2.4.2
    • Fix Version/s: 2.5
    • Component/s: None
    • Labels:
      None

      Description

      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?

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: