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

Cannot override prototype members of DB type in javascript shell.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Gone away
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: JavaScript, Shell
    • Labels:
    • Operating System:
      ALL

      Description

      In the shell, when connected to a databse, the following actual behavior occurs:

      > DB.prototype.x = 1
      1
      > db.x
      1
      > db.x = 2
      2
      > db.x
      1
      

      The expected behavior differs in that the last db.x examination should return 2, though DB.prototype.x should continue to return 1. Instances of DB aren't properly respecting prototype overriding behavior.

      For comparison,

      > function Y() {}
      > Y.prototype.y = 1
      1
      > y = new Y();
      { "y" : 1 }
      > y.y
      1
      > y.y = 2
      2
      > y.y
      2
      > Y.prototype.y
      1
      > 
      

      Note that assigning to y.y hides the prototypical value Y.prototype.y, but does not replace it.

        Attachments

          Activity

            People

            Assignee:
            backlog-server-platform DO NOT USE - Backlog - Platform Team
            Reporter:
            schwerin Andy Schwerin
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: