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

Delete /destroy not removing in 4.0.1

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.2
    • Affects Version/s: None
    • Component/s: None
    • None

      As per this:

      https://github.com/mongoid/mongoid/issues/3085#issuecomment-18944120

      The only way I can currently delete an embedded object is by running something like:

      r.terminals.destroy_all(_id: r.terminals.last._id)

      I thought this had been fixed in bson 2.2.2

      >> cart = StoreCart.last
      >> cart.store_cart_line_items.size
      => 1
      >> cart.store_cart_line_items.last.delete
      >> cart.save
      >> cart.reload.store_cart_line_items.size
      => 1
      >> cart = StoreCart.last
      >> cart.store_cart_line_items.size
      => 1
      
      --
      
      >> pid = Store.last.store_products.first.id.to_s
      >> cart.store_cart_line_items.destroy_all(product_id: pid )
      >> cart.reload.store_cart_line_items.size
      => 0
      

      References:

      https://github.com/mongoid/mongoid/issues/3085#issuecomment-18944120
      https://github.com/mongoid/mongoid/pull/3563

      Mongoid 4.0.1
      MongoDB shell version: 2.6.5
      Bson 2.3.0
      ruby 2.2.0

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

              Created:
              Updated:
              Resolved: