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

Shell improperly deletes objects

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Shell
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      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

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: