-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: BSON
-
None
The new bsoncodec package handles encoding and decoding of known types, but it doesn't handle encoding known types to their non-default BSON types. For instance, while decoding into an int64 for a DateTime type could be supported, there wouldn't be a way to properly encode the int64 to a DateTime BSON type. This violates the ability to round trip types in the BSON library and it causes information loss by default. For this reason, the BSON decoders do not currently support decoding a DateTime into an int64. Users who need this functionality required to register custom codecs to handle this case, or to handle BSON marshaling on their own.
A better solution is to allow users to tag their struct values with a bsontype struct field. This would allow the user to pass information to the encoders and decoders so they can properly handle round trip enabled encoding and decoding without information loss for non standard BSON types. This would enable users to encode a string to essentially any BSON type and also decode it. This is especially useful for ObjectIDs and date time strings.
- is depended on by
-
GODRIVER-565 Decode date field to int64 get zero value
- Closed
- related to
-
GODRIVER-1927 Unexpected characters are reported as invalid numbers
- Backlog