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'.)
- is duplicated by
-
MONGOID-5279 Undocument Model#set breakage in 7.4.0
- Closed
- is related to
-
MONGOID-5340 Add $set behavior change in Mongoid 7.1 to release notes
- Closed