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

shell no longer validates "toString" field name in document, prints out [object]

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.4.10, 2.6.1-rc1
    • Shell
    • None
    • ALL

    Description

      In earlier versions (tested 2.2.6), the mongo shell refused values (other than functions) for the field named "toString", as it would overwrite the internal method to print the document.

      MongoDB shell version: 2.2.6
      connecting to: test
      > a = {foo: "bar", toString: "test"}
      Sun May  4 15:06:52 TypeError: x.toString is not a function src/mongo/shell/utils.js:1027

      This is no longer validated in 2.4.x and 2.6.x

      MongoDB shell version: 2.4.9
      connecting to: test
      > a = {foo: "bar", toString: "test"}
      [object]
      > a
      [object]

      MongoDB shell version: 2.6.1-rc0
      connecting to: test
      > a = {foo: "bar", toString: "test"}
      [object]
      > a
      [object]

      These documents are displayed with [object] in the shell. This is confusing to users who are not aware of the issue, and also outputs invalid JSON.

      Attachments

        Activity

          People

            backlog-server-platform DO NOT USE - Backlog - Platform Team
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: