Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-13551

Shell improperly deletes objects

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Shell
    • None
    • ALL
    • Hide

      N = 1000

      // create data
      db.coll.drop()
      for (i = 0; i < N; i++) {
      newItem =

      {"a":1,"b":2}

      ;
      db.coll.insert(newItem);
      }

      // update
      db.coll.find().forEach(function (obj) {
      obj.map =

      { "a":obj.a, "b":obj.b }

      ;
      delete obj.a;
      delete obj.b;
      db.coll.save(obj);
      });
      //

      // check
      db.coll.aggregate( { $group :
      { _id : "$map.a",
      totalA :

      { $sum : "$map.b" }

      }
      });

      The output should be 2000, it is 1798 in 2.6.0 and 1800 in 2.4.10.

      Show
      N = 1000 // create data db.coll.drop() for (i = 0; i < N; i++) { newItem = {"a":1,"b":2} ; db.coll.insert(newItem); } // update db.coll.find().forEach(function (obj) { obj.map = { "a":obj.a, "b":obj.b } ; delete obj.a; delete obj.b; db.coll.save(obj); }); // // check db.coll.aggregate( { $group : { _id : "$map.a", totalA : { $sum : "$map.b" } } }); The output should be 2000, it is 1798 in 2.6.0 and 1800 in 2.4.10.

    Description

      The mongo shell deletes objects using delete rather then just delete the reference.

      Attachments

        Activity

          People

            Unassigned Unassigned
            charlie.page@10gen.com Charlie Page
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: