-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Major - P3
-
Affects Version/s: 5.0.0
-
Component/s: None
-
None
-
Environment:OS X Version 10.9.2
Like https://jira.mongodb.org/browse/MONGOID-815 I am unable to update hash attributes in mongoid 5.0.0
2.1.7 :001 > class Something 2.1.7 :002?> include Mongoid::Document 2.1.7 :003?> 2.1.7 :004 > field :data, :type => Hash 2.1.7 :005?> end => #<Mongoid::Fields::Standard:0x007fa0832885e0 @name="data", @options={:type=>Hash, :klass=>Something}, @label=nil, @default_val=nil> 2.1.7 :028 > Something.delete_all D, [2015-09-30T16:03:26.098733 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.count | STARTED | {"count"=>"somethings", "query"=>{}} D, [2015-09-30T16:03:26.136089 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.count | SUCCEEDED | 0.037203s D, [2015-09-30T16:03:26.172693 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.delete | STARTED | {"delete"=>"somethings", "deletes"=>[{"q"=>{}, "limit"=>0}], "writeConcern"=>{:w=>1}, "ordered"=>true} D, [2015-09-30T16:03:26.209038 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.delete | SUCCEEDED | 0.036203s => 1.0 2.1.7 :029 > Something.create :data => {"a" => 55} D, [2015-09-30T16:03:34.432691 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.insert | STARTED | {"insert"=>"somethings", "documents"=>[{"_id"=>BSON::ObjectId('560c4e2664b1f37233000003'), "data"=>{"a"=>55}}], "writeConcern"=>{:w=>1}, "ordered"=>true} D, [2015-09-30T16:03:34.469041 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.insert | SUCCEEDED | 0.036208000000000004s => #<Something _id: 560c4e2664b1f37233000003, data: {"a"=>55}> 2.1.7 :030 > s = Something.find("560c4e2664b1f37233000003") D, [2015-09-30T16:03:46.981901 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.find | STARTED | {"find"=>"somethings", "filter"=>{"_id"=>BSON::ObjectId('560c4e2664b1f37233000003')}} D, [2015-09-30T16:03:47.026019 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.find | SUCCEEDED | 0.043991s => #<Something _id: 560c4e2664b1f37233000003, data: {"a"=>55}> 2.1.7 :031 > s["data"] => {"a"=>55} 2.1.7 :032 > s["data"]["a"]=33 => 33 2.1.7 :033 > s.changes => {} 2.1.7 :034 > s["data"] => {"a"=>33} 2.1.7 :035 > s.save! => true 2.1.7 :036 > s["data"] => {"a"=>33} 2.1.7 :037 > s.reload D, [2015-09-30T16:10:32.711795 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.find | STARTED | {"find"=>"somethings", "filter"=>{:_id=>BSON::ObjectId('560c4e2664b1f37233000003')}} D, [2015-09-30T16:10:32.747745 #29235] DEBUG -- : MONGODB | staging.db.donde.io:27000 | backend-staging.find | SUCCEEDED | 0.035806s => #<Something _id: 560c4e2664b1f37233000003, data: {"a"=>55}> 2.1.7 :038 > s["data"] => {"a"=>55}
If I create a deep copy of the hash attribute, modify the copy and assign it back to the model object, updates are properly saved.
- is related to
-
MONGOID-4248 Array attributes Not updating
- Closed