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

autosave should not issue an extra update when saving a document with a subdocument which has changed

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

      class Car
        include Mongoid::Document
        embeds_one :seat
        field :a
      end
      
      class Seat
        include Mongoid::Document
        embedded_in :car
        field :a
        validates_presence_of :car
      end
      
      > c=Car.new
      > c.build_seat
      > c.save
      MOPED: 127.0.0.1:27017 INSERT database=x collection=cars documents=[{"_id"=>"520a9f5f530a6941c1000001", "seat"=>{"_id"=>"520a9f61530a6941c1000002"}}] flags=[] (0.0660ms)
      > c.seat.a='foo'
      > c.save
      MOPED: 127.0.0.1:27017 UPDATE database=x collection=cars selector={"_id"=>"520a9f5f530a6941c1000001", "seat._id"=>"520a9f61530a6941c1000002"} update={"$set"=>{"seat.a"=>"foo"}} flags=[] (0.1171ms)
      MOPED: 127.0.0.1:27017 UPDATE database=x collection=cars selector={"_id"=>"520a9f5f530a6941c1000001"} update={"$set"=>{"seat.a"=>"foo"}} flags=[] (0.0908ms)
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            ghost Deleted user
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: