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

JSON parser doesn't accept simple DBRef $id values, like ints or strings

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.2, 2.5.0
    • Affects Version/s: 2.4.0
    • Component/s: JavaScript
    • None
    • Minor Change
    • ALL

      It's hard to find any documentation on DBRefs.

      But I believe the intention is that the $id field can be anything that can be stored as _id.

      The JSON parser however insists that it is a quoted 24 char hex string, or "ObjectId(...)".

      See:
      https://github.com/mongodb/mongo/blob/master/src/mongo/db/json.cpp#L663
      https://github.com/mongodb/mongo/blob/master/src/mongo/db/json.cpp#L467

      These should be valid objects:

      fromjson("{myref:DBRef('coll',1)}")
      fromjson("{myref:{$ref:'coll',$id:1}}")
      

      But they both fail.

            Assignee:
            sverch Shaun Verch
            Reporter:
            thomas.rueckstiess@mongodb.com Thomas Rueckstiess
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: