[GODRIVER-953] way to force decoding ints into string Created: 10/Apr/19  Updated: 27/Oct/23  Resolved: 30/Mar/20

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Alexander Assignee: Isabella Siu (Inactive)
Resolution: Gone away Votes: 0
Labels: mgocompat
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to GODRIVER-938 cannot convert types that use mgobson... Closed
is related to GODRIVER-1216 mgo compatible bson registry Closed
Epic Link: mgo migration tool

 Description   

I have following field in struct:

Codes map[string]string `bson:"codes"`

Sometimes value of this map is  numberLong and got an error:

cannot decode 64-bit integer into a string type

With mgo driver this case is ok, but in official driver I can't load this collection at all.



 Comments   
Comment by Isabella Siu (Inactive) [ 15/Jan/20 ]

Hi abonec,

What version of mgo are you using? The globalsign fork of it does not decode 64-bit integers into strings, it just skips it silently.

Comment by Alexander [ 10/Apr/19 ]

But it would be strings and ints. It would be great if there will be an option to force convert to the target type.

Comment by generalking [ 10/Apr/19 ]

you should define like this

//
Codes map[string]interface{} `bson:"codes"`

 

Generated at Thu Feb 08 08:35:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.