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

Mongoid::Paranoia does not trigger cascading deletes/destroys in associated documents

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

      Something I found in the code:

      in mongoid/persistence.rb

      def _remove(options = {})
      if Remove.new(self, options).persist
      self.destroyed = true
      cascading_remove!
      end; true
      end

      in mongoid/paranoia.rb

      def _remove(options = {})
      now = Time.now
      collection.update({ :_id => self.id }, { '$set' => { :deleted_at => Time.now } })
      @attributes["deleted_at"] = now
      true
      end

      Paranoia#_remove doesn't trigger cascading_remove!, ergo any associated documents are not "deleted" when deleted documents using Mongoid::Paranoia

            Assignee:
            Unassigned Unassigned
            Reporter:
            evansagge Evan Sagge
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: