Description
I've got the code below that should ignore truncation errors, but returns an error indicating it can't truncate:
type collStats struct {
|
CollectionName string `bson:"collStats"`
|
Scale *int64 `bson:"scale" valid:"optional,gt(0)~scale must be a number > 0"`
|
}
|
|
|
var cmd collStats
|
decodeContext := bsoncodec.DecodeContext{
|
Registry: bson.DefaultRegistry,
|
Truncate: true,
|
}
|
err := bson.UnmarshalWithContext(decodeContext, doc, &cmd)
|
if err != nil {
|
return nil, mongoerrors.Wrap(err, mongoerrors.CodeFailedToParse, "unable to parse the collStats command")
|
}
|
produces the following error:
{"collStats": "foo", "scale": 29.821 } -> IntDecodeValue can only truncate float64 to an integer type when truncation is enabled
|