-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: 7.0.3
-
Component/s: Persistence
-
Labels:None
-
Environment:OS X 10.14 and Ubuntu 18.04 LTS
When attempting to set a specific key within Hash field using the atomic
set
method, the entire Hash is written rather than just the specified key.
Given a class:
class Lead include Mongoid::Document field :additional_info, type: Hash end
Running the following:
2.6.2 :001 > lde = Lead.first 2.6.2 :002 > lde.additional_info => {"x"=>1, "y"=>2, "z"=>3} 2.6.2 :003 > lde.set("additional_info.x" => 0)
Produces this query:
{"update"=>"leads", "ordered"=>true, "lsid"=>{"id"=><BSON::Binary:0x70205608300400 type=uuid data=0xc5e017742a694cd8...>}, "updates"=>[{"q"=>{"_id"=>"lde_12Vwbb66NgkdCL"}, "u"=>{"$set"=>{"additional_info"=>{"x"=>0, "y"=>2, "z"=>3}}}, "multi"=>false, "...
You can see from the query that the entire Hash is being written.
- split from
-
MONGOID-3228 Hash field types are prone to race conditions due to the entire field being set at once
- Closed