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

replace_one does not validate all keys for update operators

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      When using replace_one function, it only checks for the first argument to see if it is update operator or not. If first key is an update operator, it raises ValueError, whereas if it's after a valid key, it raises a WriteError from the server. This should be caught at the driver level instead of server level.

      Example -

      col.replace_one({"name":"shrey"}, {"$set":{"hello":"world"}})
      

      The above line raises a ValueError, whereas the below line raises a WriteError

      col.replace_one({"name":"shrey"}, {"name": "name_1", "$set":{"hello":"world"}})
      

            Assignee:
            prashant.mital Prashant Mital (Inactive)
            Reporter:
            shreybatra97@gmail.com Shrey Batra
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: