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

Cannot override prototype members of DB type in javascript shell.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: JavaScript, Shell
    • ALL

      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.

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

              Created:
              Updated:
              Resolved: