-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
One of the reason I switched over to mongoid is that is performed atomic updates correctly. If I update one field, it should only run an update to the DB with one field, not all fields. this helps prevent overwrites from occurring in concurrent systems.
But with the current version of Mongoid (beta18) I'm seeing this no longer the case. For example.
I create a record where the insert looks like this.
MONGODB test_db['locations'].insert(
[
{
"_id"=>BSON::ObjectID('4c939ed120252cb5d30000ff'),
"name"=>"Other Music Inc",
"url"=>"http://maps.google.com/maps/place?cid=6583927858764579749",
"geo_location"=>
,
"address"=>
,
"created_at"=>2010-09-17 17:01:05 UTC,
"updated_at"=>2010-09-17 17:01:05 UTC
}
]
)
And then I do the following on a mongoid object.
location.contact_email = "someone@interested.com"
location.token = "3c842fc1100b235116993dca21ac741c8f6e90c2"
location.token_xpr = Time.now.utc + 30.days
location.events << update_event
location.save
I see this gets run to the DB
MONGODB test_db['locations'].update(
,
{
"$set"=>
,
"$pushAll" => {
"events"=>[
{
"edits"=>
,
"info"=>"Invite contact 'someone@interested.com'",
"created_at"=>2010-09-17 17:01:05 UTC,
"_id"=>BSON::ObjectID('4c939ed120252cb5d3000102'),
"_type"=>"UpdateEvent"
}
]
}
}
)
It seems to be putting all the attributes back into the record. Why would this be happening?