replace_one does not validate all keys for update operators

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 (Inactive)
            Reporter:
            Shrey Batra
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: