mongoid/mongoid — Issue #1337: HABTM inverse_of relationship using $set instead of $pushAll
Author: radicaled
Created: 2011-10-09 07:00:05+00:00
State: open

On the other side of an HABTM relationship, on the inverse_of model Mongoid is using $set instead of $pushAll to update the "*_ids" attribute. This can cause data loss in a quick moving application.

Here's a snippet from my logs:
```
MONGODB laylow_development['users'].update({"_id"=>BSON::ObjectId('4e72a09573036a70ca000004')}, {"$set"=>{"interaction_ids"=>[BSON::ObjectId('4e9142fb73036a3f61000005')], "updated_at"=>2011-10-09 06:50:11 UTC}})
MONGODB laylow_development['interactions'].update({"_id"=>BSON::ObjectId('4e9142fb73036a3f61000005')}, {"$pushAll"=>{"participant_ids"=>[BSON::ObjectId('4e72a09573036a70ca000004')]}})
```