Improve BasicDBObject.parse to support DBRefs with $db field

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • 3.7.0
    • Affects Version/s: None
    • Component/s: Codecs
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Currently, if you call BasicDBObject.parse on a json string like the following:

      { myDbRef: {
          $ref: "collection",
          $id: { $oid: "59ce7963a43f254534602da9" },
          $db: "myDB"
      }
      

      The Java Driver will return an object that contains the "$ref" and "$id" as supplied, but drops the "$db". The cause for this seems to be these lines: https://github.com/mongodb/mongo-java-driver/blob/master/driver/src/main/com/mongodb/DBObjectCodec.java#L359-L363 which discard the "$db" value and use the constructor for DBRef that doesn't include $db.

      The verifyForDBRef function should be modified to use both constructors based on whether or not "$db" is available

              Assignee:
              Ross Lawley
              Reporter:
              Jonathan Balsano
              None
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: