Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4593

Model.set hash merge behavior does not match $set

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0.rc0, 7.0.2
    • Affects Version/s: 7.0.1
    • Component/s: None
    • None

      During an investigation into a bugfix for MONGOID-4525, Oleg Pudeyev found that the current Mongoid::Persistable::Settable#set behavior doesn't match MongoDB's $set operator.

      Text from issue pasted below:

      One problem with this implementation is it merges leaf hash values instead of writing them as is (which is what mongo shell does).

      I.e. if I have {'a' => {'b' => 'c'}} and I set 'a' => {'d' => 'e'}, the result should be {'a' => {'d' => 'e'}} but it currently is {'a' => {'b' => 'c', 'd' => 'e'}}. (To achieve the merge on the leaf level the operation should be to set 'a.d' => 'e'.)

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            michael.dehoog@coinbase.com Michael de Hoog
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: