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

Save on embedded object is sometimes not persisted

    • Type: Icon: Task Task
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None
    • None

      I've just run all my tests against v5.0.0.beta. All passed on f56b96b but on the beta I have a test where I am saving on an embedded object. This appears to fail silently.

      This is happening in an Rspec and only very rarely. I have no idea why. I looked through a diff of the code and nothing special jumps out other than the beta of the mongo driver.

      Here's example code that shows what is happening...

      class Parent
        include Mongoid::Document
        include Mongoid::Timestamps
      
        embeds_many :child, class_name: 'Child', inverse_of: :parent, validate: false, cascade_callbacks: true
      end
      
      class Child
        include Mongoid::Document
        include Mongoid::Timestamps
      
        embedded_in :parent
      end
      
      raise unless child.some_attribute == 1
      child.some_attribute = 2
      child.save
      new_child = Child.<get from db>
      raise unless new_child.some_attribute == 2 # raises here
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            lukaso lukaso
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: