Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2913

Driver does not follow CRUD spec for update/replace operations

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Spec Comp
    • Labels:
      None

      CRUD specification requires that "The update family of operations require that the update document parameter MUST have only atomic modifiers." and that "The replace family of operations require that the replacement document parameter MUST NOT begin with an atomic modifier.". Ruby driver does not enforce those requirements:

      client["users"].insert_one({_id: 1, x: "foo"})
      => #<Mongo::Operation::Insert::Result:0x238900 ...>
      irb(main):007:0> client["users"].update_one({_id: 1}, {x: "bar"}) # No error raised
      => #<Mongo::Operation::Update::Result:0x264500 ...>
      irb(main):008:0> client["users"].find().to_a
      => [{"_id"=>1, "x"=>"bar"}]
      client["users"].replace_one({_id: 1}, {'$set' => {x: 'bazzzzz'}})
      => #<Mongo::Operation::Update::Result:0x432840 ...> # No error raised
      irb(main):010:0> client["users"].find().to_a
      => [{"_id"=>1, "x"=>"bazzzzz"}]
      

      We should comply with spec requirement. However, fixing this will change behavior of helpers, so we should probably consider this as a breaking change.

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            dmitry.rybakov@mongodb.com Dmitry Rybakov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: