Converting a DBRef from JSON to BSON results in an ObjectId type:
{ "dbref": { "$ref": "collection", "$id": { "$oid": "56315a7c6118fd1b920270b1" }}}
Results in:
0 : 18 00 00 00 07 64 62 72 65 66 00 56 31 5a 7c 61 [.....dbref.V1Z|a] 10 : 18 fd 1b 92 02 70 b1 00 [.....p..]
Peaking into bson-json.c revealed that libbson attempts to convert DBRef objects to deprecated DBPointer types. I'm not sure why an ObjectId is being generated, but even the intentional behavior seems incorrect.
DBRef objects should allow any value as their $id (obviously arrays cannot be IDs, but I assume the server only enforces this on documents' _id field value, not DBRefs). Additionally, DBRef objects may contain additional fields (e.g. $db, and any non-$-prefixed fields thereafter). Correct behavior would be to simply convert DBRef objects to embedded documents.
- is depended on by
-
PHPC-474 fromJSON() does not handle DBRef documents
- Closed
- is related to
-
CDRIVER-1033 dbpointer not handled in bson-json.c
- Closed