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

Shell can't print invalid or native functions stored in a document

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: 2.6.11, 3.0.7, 3.2.0-rc5
    • Component/s: JavaScript, Shell
    • None
    • Fully Compatible
    • ALL
    • Hide
      db.test.insert({a:print})
      db.test.find()
      
      Show
      db.test.insert({a:print}) db.test.find()
    • TIG 11 (03/11/16)

      attempting to store and find an invalid or native function from the shell gives a SyntaxError.

      It looks like the cause is that the shell attempts to eval a function in a document, which would fail if the function is invalid.

      2015-12-02T15:04:39.330-0500 E QUERY    [thread1] SyntaxError: missing ] after element list :
      tojsonObject@src/mongo/shell/types.js:701:13
      tojson@src/mongo/shell/types.js:647:17
      DBQuery.prototype.shellPrint@src/mongo/shell/query.js:522:65
      shellPrintHelper@src/mongo/shell/utils.js:462:1
      @(shell2):1:1
      

            Assignee:
            robert.guo@mongodb.com Robert Guo (Inactive)
            Reporter:
            robert.guo@mongodb.com Robert Guo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: