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

Implement touch: false for embedded documents, permitting saving of child without touching parent

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Associations
    • None

      Please see https://github.com/mongodb/mongoid/pull/5202 for a demonstration of these issues and further commentary.

      • Embedded associations with touch: false will incorrectly touch the parent when touching the child:
      class Hospital
        include Mongoid::Document
        include Mongoid::Timestamps
        embeds_many :floors, inverse_of: :hospital
      end
      
      class Floor
        include Mongoid::Document
        include Mongoid::Timestamps
        embedded_in :hospital, touch: false
      end 
      
      building = Hospital.create!
      floor = building.floors.create!
      floor.touch
      building.updated_at # it is later than it should be

      I have put up a PR which I believe illustrates these issues a little more clearly: https://github.com/mongodb/mongoid/pull/5204

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: