How do I turn on Truncate for float64?

889 views
Skip to first unread message

Paul A. Fortin

unread,
Dec 3, 2019, 11:16:53 AM12/3/19
to mongodb-go-driver
I am getting this error ("IntDecodeValue can only truncate float64 to an integer type when truncation is enabled") in my logs and tried to see how to turn truncate on but I cannot see how to do that.  Can someone help me figure that out please?

Divjot Arora

unread,
Dec 3, 2019, 11:31:02 AM12/3/19
to mongodb-go-driver
Hi Paul,

Sorry this isn't documented yet. I actually have some proposed documentation for this and other struct behavior in https://github.com/mongodb/mongo-go-driver/pull/239 right now. You can do this with the "truncate" struct tag on the integer field that is causing the error. For example:

type Foo struct {
   
Bar int `bson:",truncate"`
}

Paul A. Fortin

unread,
Dec 3, 2019, 11:56:14 AM12/3/19
to mongodb-go-driver
Hi Divjot,

That worked but I had to add it to all the ints since I did not know which one was the culprit..  I'll hunt it down...

Thanks!!!

Reply all
Reply to author
Forward
0 new messages