-
Type: Bug
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Attributes
-
None
-
Ruby Drivers
#!/usr/bin/env ruby require 'bundler/inline' gemfile do source 'https://rubygems.org' gem 'mongoid', '8.0.8' end require 'mongoid' Mongoid.configure do |config| config.clients.default = { hosts: ['localhost'], database: 'test' } config.legacy_attributes = false end puts Mongoid::VERSION puts Mongo::VERSION class Purse include Mongoid::Document field :brand, type: String embedded_in :person end class Person include Mongoid::Document include Mongoid::Attributes::Dynamic field :name, type: String embeds_many :purses, store_as: :ps end p = Person.new(ps: [{}]) p.save person = Person.find(p.id) before_document = person.as_document.dup person.purses.first.brand = "Gucci" after_document = person.as_document puts "Before_document:" pp before_document # expects this to not include Gucci since it was cloned before the document was updated puts "After_document:" pp after_document
In v7.5.4 with legacy_attributes enabled, cloning works fine and shows the correct differences between the two documents. After v8.0.8 upgrade, we discovered that cloning will only work as expected with legacy_attributes disabled. I believe the regression happened after this change - https://github.com/mongodb/mongoid/pull/5153.