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

ValueWriter cannot serialize objects that have properties with type Symbol

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • ALL

      MongoDB Enterprise > db.symbol.insert({_id: 1, sym: Symbol("foo")})
      Error: unable to convert JavaScript property to mongo element sym :
      addToOperationsList@src/mongo/shell/bulk_api.js:606:28
      Bulk/this.insert@src/mongo/shell/bulk_api.js:649:20
      DBCollection.prototype.insert@src/mongo/shell/collection.js:317:9
      @(shell):1:1
      

      The shell wants to use ValueWriter to convert the JSON document (with its Symbol property) to BSON, but ValueWriter is missing a case for the Symbol object, which should be translated to a BSONType::Symbol.

      https://github.com/mongodb/mongo/blob/581c58c475a872e25b2e3bf7cf5ccd52425ef7c7/src/mongo/scripting/mozjs/valuewriter.cpp#L248-L278

            Assignee:
            projjal.chanda@mongodb.com Projjal Chanda
            Reporter:
            justin.seyster@mongodb.com Justin Seyster
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: