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

Shell improperly deletes objects

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
      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.

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

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

              Created:
              Updated:
              Resolved: