[CDRIVER-444] no support for database name in bson_iter_dbpointer() Created: 17/Oct/14  Updated: 05/Nov/14  Resolved: 04/Nov/14

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.0.2
Fix Version/s: 1.1.0

Type: Bug Priority: Major - P3
Reporter: Jerome Lebel Assignee: Mira Carey
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

According to:
http://docs.mongodb.org/manual/reference/database-references/#dbrefs

We should be able to have database name parameter.



 Comments   
Comment by Mira Carey [ 05/Nov/14 ]

My apologies on this one, I didn't realize that dbref's and dbpointers are completely different.

The dbpointer type is a deprecated bson type that only supports oid and a string which can be a collection or a namespace.

Dbref is a convention amongst drivers that allows for '$' prefixed fields assuming the first three fields are '$ref', '$id' and optionally '$db'. It's not actually a native bson type, but instead a special case for validation.

I'll be upgrading bson_validate to allow that case through.

Comment by Mira Carey [ 04/Nov/14 ]

After looking at several other drivers and the server codebase, I think I'm going to close this out as won't fix.

My rationale is:

  • bson itself only offers storage for a string and an oid in a dbpointer
  • The string storage available can be either a collection, or a full namespace (I.e. "db.collection")
  • libbson doesn't offer proxy objects aside from oid for any of the complex types. Instead we offer portable access to the data members.

So basically, all I'd really want to do would be to rename the documentation to collection/namespace. But at this point dbpointers are fully deprecated, so I'm leaving the api as is.

If you need access to the db param, you can check the "collection" return value for a '.' and substring.

Comment by Mira Carey [ 28/Oct/14 ]

Referring to bsonspec.org, the dbpointer type is stored as a string and what effectively is an oid, so there's nothing useful to do beyond a rename from the bson_append or bson_iter api perspective. Additionally, there's no notion of a collection in the server code at all. Instead it seems that the collection field should really be a namespace ("db.collection" format).

I had the notion to support the '$db' syntax for json parsing and dumping, while still storing in namespace format, but I'd like to dig around and do a bit more research since no '$db' field is mentioned in MongoDB Extended JSON

Generated at Wed Feb 07 21:09:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.