[SERVER-9082] JSON parser doesn't accept simple DBRef $id values, like ints or strings Created: 22/Mar/13  Updated: 11/Jul/16  Resolved: 29/Mar/13

Status: Closed
Project: Core Server
Component/s: JavaScript
Affects Version/s: 2.4.0
Fix Version/s: 2.4.2, 2.5.0

Type: Bug Priority: Major - P3
Reporter: Thomas Rueckstiess Assignee: Shaun Verch
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-9045 mongoimport doesn't accept dbref Closed
Related
related to DOCS-1289 mongo shell DBRef is not documented Closed
related to DOCS-1306 Backport extended json dbref changes ... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Participants:

 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.



 Comments   
Comment by auto [ 29/Mar/13 ]

Author:

{u'date': u'2013-03-28T14:41:57Z', u'name': u'Shaun Verch', u'email': u'shaun.verch@10gen.com'}

Message: SERVER-9082 Accept any valid value in id field of dbref
Branch: v2.4
https://github.com/mongodb/mongo/commit/9ba71622c9cf2af20c72469601aaf0eebd5f6e4c

Comment by auto [ 29/Mar/13 ]

Author:

{u'date': u'2013-03-28T14:41:57Z', u'name': u'Shaun Verch', u'email': u'shaun.verch@10gen.com'}

Message: SERVER-9082 Accept any valid value in id field of dbref
Branch: master
https://github.com/mongodb/mongo/commit/0b6737c2ddd58df25eb41c477c9dc639014b0ebe

Comment by Scott Hernandez (Inactive) [ 27/Mar/13 ]

It has been fixed but not backported nor deployed: DOCS-1306

Comment by Shaun Verch [ 27/Mar/13 ]

The docs at http://docs.mongodb.org/manual/reference/mongodb-extended-json/ should also be updated to reflect the correct specification for DBRef.

Generated at Thu Feb 08 03:19:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.