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

Default order on embeds_many does not destroy models placed into association via identity map

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Associations
    • Labels:
    • 3

      Using the models in MONGOID-4672:

      (byebug) manufactory.products
      []
      (byebug) Product.create!(manufactory:manufactory,name:'car')
      D, [2018-12-14T13:08:08.317659 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.update | STARTED | {"update"=>"manufactories", "ordered"=>true, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00007f249c0b20f8 @seconds=1544810801, @increment=1>, "signature"=>{"hash"=><BSON::Binary:0x69897606762480 type=generic data=0x0000000000000000...>, "keyId...
      D, [2018-12-14T13:08:08.325598 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.update | SUCCEEDED | 0.008s
      #<Product _id: 5c13f188ce4ef375ff03ab0e, name: "car">
      (byebug) manufactory.products
      [#<Product _id: 5c13f188ce4ef375ff03ab0e, name: "car">]
      (byebug) manufactory.products.destroy_all
      D, [2018-12-14T13:08:13.257894 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.update | STARTED | {"update"=>"manufactories", "ordered"=>true, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00007f249c0e3e28 @seconds=1544810888, @increment=1>, "signature"=>{"hash"=><BSON::Binary:0x69897606864500 type=generic data=0x0000000000000000...>, "keyId...
      D, [2018-12-14T13:08:13.262688 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.update | SUCCEEDED | 0.005s
      2
      (byebug) manufactory.products
      [#<Product _id: 5c13f188ce4ef375ff03ab0e, name: "car">]
      (byebug) manufactory.reload
      D, [2018-12-14T13:08:35.728465 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.find | STARTED | {"find"=>"manufactories", "filter"=>{"_id"=>BSON::ObjectId('5c13f01dce4ef375ff03ab08')}, "$readPreference"=>{"mode"=>"primary"}, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00007f249c0e3e28 @seconds=1544810888, @increment=1>, "signature"=>{"ha...
      D, [2018-12-14T13:08:35.740696 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.find | SUCCEEDED | 0.012s
      #<Manufactory _id: 5c13f01dce4ef375ff03ab08, >
      (byebug) manufactory.products
      [#<Product _id: 5c13f188ce4ef375ff03ab0e, name: "car">]
      (byebug) manufactory.products.destroy_all
      D, [2018-12-14T13:08:40.414964 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.update | STARTED | {"update"=>"manufactories", "ordered"=>true, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00007f2490015700 @seconds=1544810912, @increment=1>, "signature"=>{"hash"=><BSON::Binary:0x69897505778420 type=generic data=0x0000000000000000...>, "keyId...
      D, [2018-12-14T13:08:40.422252 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.update | SUCCEEDED | 0.007s
      1
      (byebug) manufactory.products
      []
      (byebug) manufactory.reload
      D, [2018-12-14T13:09:48.858056 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.find | STARTED | {"find"=>"manufactories", "filter"=>{"_id"=>BSON::ObjectId('5c13f01dce4ef375ff03ab08')}, "$readPreference"=>{"mode"=>"primary"}, "$clusterTime"=>{"clusterTime"=>#<BSON::Timestamp:0x00007f2490054428 @seconds=1544810920, @increment=2>, "signature"=>{"ha...
      D, [2018-12-14T13:09:48.875057 #30207] DEBUG -- : MONGODB | localhost:27100 | my_db.find | SUCCEEDED | 0.017s
      #<Manufactory _id: 5c13f01dce4ef375ff03ab08, >
      (byebug) manufactory.products
      []
      

      Creating a standalone instance of product adds it to the list of products in manufactory, but calling `destroy_all` on the list of products does not destroy this instance.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: