Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1174

Assigning an array to a has_many destroys documents

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      I ran into an issue upgrading from 2.0.2 to 2.1.8 last night. It seems to that assigning an array of documents to a has_many field deletes all the documents. I was using this approach to batch load a bunch of has_many associations, rather than making multiple DB roundtrips, and managed to lose a bunch of data (MongoHQ helped me recover from a backup, phew).

      Here's a gist demonstrating the issue:
      https://gist.github.com/1161008

      This seems non-optimal to me! I've since worked around it by getting rid of the relationship altogether and just emulating the bits I needed.

            Assignee:
            Unassigned Unassigned
            Reporter:
            mrkurt Kurt Mackey
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: