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

Can't empty to one sided many to many relation in embedded document

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

      https://github.com/mongoid/mongoid/issues/3019

      This example works on 3.1.3 but fails on 4.0.0 (f703270).

      I think when the defect above was fixed it create a new problem.

      class Bundle
        embeds_many :items
      end
      
      class Item
        embedded_in :bundle
      end
      
      
      bundle = Bundle.new(items: Item.new)
      bundle.persisted? # => false
      bundle.items.first.persisted? # => false
      bundle.items = [] 
      
      

      this results in the error below
      NoMethodError: undefined method 'atomice_selector' for nil:NilClass

       
      def embedded_atomic_selector
        if persisted? && _id_changed?
          _parent.atomic_selector
        else
           binding.pry
           _parent.atomic_selector.merge("#{atomic_path}._id" => _id)
        end
      end
      
      _parent # => nil
      

      I think the code that was checking the parent needs to be added back but I can't be total sure.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            newdark newdark
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: