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

Returning WriteResult from eval fails

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.6.0
    • Component/s: JavaScript, Shell
    • Server Security
    • ALL

      When you run something like this it fails to deserialize the WriteResult on the client (shell):

      > db.eval(function(){return db.nothing.update({fake:1},{$set:{a:1}})})
      2014-04-21T08:56:42.415-0400 ReferenceError: writeConcern is not defined
      > var res = db.eval(function(){return db.nothing.update({fake:1},{$set:{a:1}})})
      >s res.nInserted
      0
      > res.tojson()
      2014-04-21T08:58:49.077-0400 ReferenceError: singleBatchType is not defined
      
      // converting to json from WriteResult works much better.
      > db.eval(function(){return db.nothing.update({fake:1},{$set:{a:1}}).tojson()})
      { "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 }
      

      This is probably due to the fact that most of the types are defined in an enclosure and not public, but more investigation should be done.

            Assignee:
            backlog-server-security [DO NOT USE] Backlog - Security Team
            Reporter:
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: