-
Type: New Feature
-
Resolution: Won't Do
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
In porting mongotop to the new driver, I discovered a subtle incompatibility. The top command returns a document like this:
{ "totals" : { "note" : "all times in microseconds", "admin.system.roles" : { ... }, "admin.system.version" : { ... }, ... } }
mongotop wants to decode that into a type like this:
type Top struct { Totals map[string]NSTopInfo `bson:"totals"` }
The problem is that the 'note' field is a string, not a document, so can't be decoded to a "NSTopInfo" struct. mgo's Unmarshal behavior is: "if the value would not fit the type and cannot be converted, it's silently skipped", so with mgo, the 'note' field was ignored.
The Go driver is strict – and errors on the 'note' field. On the one hand, this is correct behavior, but on the other hand it may cause surprising and subtle user pain converting from mgo where irregular structures like the 'top' output could be handled more seamlessly.
I have no strong feelings one way or another, but thought there should be some discussion of whether/how to address or avoid this user pain.
- is related to
-
GODRIVER-1216 mgo compatible bson registry
- Development Complete