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

XMLWordPrintableJSON

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

      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:
              Shaun Verch (Inactive)
              Reporter:
              Thomas Rueckstiess (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: