HABTM inverse_of relationship using $set instead of $pushAll

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • 2.4.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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. Using 2.2.0 gem here.

      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')]}})
      

              Assignee:
              Unassigned
              Reporter:
              Arron Washington
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: