-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
The two main bugs:
- The decoder can't properly decode an int32 into a struct field that's an int64. As long as the values fit, we should be able to freely put int32's, int64's, and doubles into the other number types.
- The decoder cannot handle decoding into a slice when it is a field of a struct. I didn't check for maps, but from the code it looks like whenever a BSON Array is returned and we try to decode it into an array or a slice we panic.
Additionally, the unit test coverage is sparse. One idea to boost the unit test coverage would be to ensure that we support roundtripping: If a user gives us a struct to encode, we should be able to encode it and then decode back into the same type and the values should be the same. Writing test that cover the happy path for the getReflectValue method would also boost coverage.
For the slice case, it is okay to create a new slice of the correct length and assign it to the field, if users want to control their allocs they can handle unmarshaling in custom code.