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

Returning WriteResult from eval fails

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.6.0
    • JavaScript, Shell
    • Server Security
    • ALL

    Description

      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.

      Attachments

        Activity

          People

            backlog-server-security Backlog - Security Team
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: