Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-1414

ObjectId methods valueOf() and str return undefined

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: 1.8.0
    • Component/s: Shell API
    • Labels:
      None
    • Environment:
      OSX/brew
    • Not Needed

      Problem Statement/Rationale

      It appears a regression has been introduced on the mongosh helper methods on ObjectId() for valueOf() and str.

      The str getter doesn't list at all in the prototype, and calling either str or valueOf() returns undefined.

      Steps to Reproduce

      mongosh
      // str test
      typeof new ObjectId().str;
      // valueOf() test
      typeof new ObjectId().valueOf();
      // toHexString() test
      typeof new ObjectId().toHexString();
      

      Expected Results

      mongosh
      // str test
      typeof new ObjectId().str;
      string
      // valueOf() test
      typeof new ObjectId().valueOf();
      string
      // toHexString() test
      typeof new ObjectId().toHexString();
      string
      

      Actual Results

      mongosh
      // str test
      typeof new ObjectId().str;
      undefined
      // valueOf() test
      typeof new ObjectId().valueOf();
      undefined
      // toHexString() test
      typeof new ObjectId().toHexString();
      string
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            luke.prochazka@mongodb.com Luke Prochazka
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: