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

Cloning documents with deep embedded documents don't work

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.2
    • Affects Version/s: 7.0.1
    • Component/s: None
    • None

      Fixed here: https://github.com/mongodb/mongoid/pull/4504

       

      Given you have the following relations:

      class Person
        include Mongoid::Document
        embeds_one :name
      end

      class Name
        include Mongoid::Document
        embeds_many :translations
      end

      class Translation
        include Mongoid::Document
        embedded_in :name
      end

      If you try to clone the `person`, you get the following error:

      Person.new(name: Name.new(translations: [Translation.new])).clone

      {{NoMethodError: undefined method `translations' for #<Person _id: 5b364ccba64769539ad9b0c4, > }}
      from mongoid/lib/mongoid/copyable.rb:77:in `block (2 levels) in process_localized_attributes

            Assignee:
            sam.rossi@mongodb.com Samuel Rossi (Inactive)
            Reporter:
            alexandrebini Alexandre Bini
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: