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

Unable to Destroy Embedded Document

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None
    • None

      This is possibly related to MONGOID-3020 - the only difference is that the targeted document persists with the same ID.

      I'm not using a replica set - this is happening on my local machine in my test and development environments. Whenever I try to destroy an embedded document, the object appears to be deleted in memory, but persists in the database.

      (rdb:1) p record.terminals
      [
        #<ControlCenter::Terminal _id: 51a904dfba0810d1ee000016, created_at: 2013-05-31 20:15:27 UTC, updated_at: 2013-05-31 20:15:27 UTC, ... >, 
        #<ControlCenter::Terminal _id: 51a904dfba0810d1ee000017, created_at: 2013-05-31 20:15:27 UTC, updated_at: 2013-05-31 20:15:27 UTC, ... >
      ]
      (rdb:1) p record.terminals.last.destroy
      true
      (rdb:1) p record.terminals
      [
        #<ControlCenter::Terminal _id: 51a904dfba0810d1ee000016, created_at: 2013-05-31 20:15:27 UTC, updated_at: 2013-05-31 20:15:27 UTC, ... >
      ]
      (rdb:1) p record.reload.terminals
      [
        #<ControlCenter::Terminal _id: 51a904dfba0810d1ee000016, created_at: 2013-05-31 20:15:27 UTC, updated_at: 2013-05-31 20:15:27 UTC, ... >, 
        #<ControlCenter::Terminal _id: 51a904dfba0810d1ee000017, created_at: 2013-05-31 20:15:27 UTC, updated_at: 2013-05-31 20:15:27 UTC, ... >
      ]
      

      My Moped logs show what appears to be a reasonable deletion query:

      MOPED: 127.0.0.1:17017 UPDATE       database=test collection=control_center_records selector={"_id"=>"51a904dfba0810d1ee000015"} update={"$pull"=>{"terminals"=>{"_id"=>"51a904dfba0810d1ee000017"}}} flags=[] (0.2589ms)
      

      I'm not exactly sure what's happening here. Why would my object get deleted in memory, but not in the database?

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            todd Todd Blose
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: