Model.set hash merge behavior does not match $set

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 7.1.0.rc0, 7.0.2
    • Affects Version/s: 7.0.1
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 (Inactive)
              Reporter:
              Michael de Hoog
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: