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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.0
    • Fix Version/s: 2.4.2, 2.5.0
    • Component/s: JavaScript
    • Labels:
      None
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: