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

Shell ignores modified object's "_id" field

    • ALL

      If an object is returned in the shell from a query (or any other way from the server) which is then modified the result will be that the "_id" field will be ignored when being sent to a mongodb server (in the bson encoding process).

      This is a bug in javascript (shell/client) but does not effect the server, other than the client not sending the _id field. It is possible to cause this behavior with javascript on the server using $eval (db.eval) or mapReduce, in the reduce phase if the first document in the array is modified (which is not a normal usage pattern).

      Orig Description
      There's a regression in the 2.4.2 shell, where if I write an object with my own _id, the shell ignores it and creates its own ObjectId. I found this out during a data migration today when my previously working JS function destroyed an entire table's worth of data

      http://stackoverflow.com/questions/16071342/reassign-mongodb-id-in-shell
      https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/MzdEDgyl0rU

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            chengas123 Ben McCann
            Votes:
            1 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: