[GODRIVER-452] bson package unable to Decode Enum values Created: 07/Jun/18 Updated: 28/Oct/23 Resolved: 10/Sep/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | 0.0.6 |
| Fix Version/s: | 0.0.14 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sercan Degirmenci | Assignee: | Kristofer Brandow (Inactive) |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
I am trying to use new go driver but I found with regarding BSON decoding. I can reproduce the issue with the file in the attachment. The problem is with the defined types. Following EnumType has no problem with encoding but can't decode the original value. |
| Comments |
| Comment by Kristofer Brandow (Inactive) [ 10/Sep/18 ] | ||||||||||||||||||||||||||
|
Hi dgregoire, Now that Thanks, Kris | ||||||||||||||||||||||||||
| Comment by Dominic Gregoire [ 31/Aug/18 ] | ||||||||||||||||||||||||||
|
As a workaround - it's a bit of a kludge, but worth it for larger structs - you can
| ||||||||||||||||||||||||||
| Comment by Kristofer Brandow (Inactive) [ 01/Aug/18 ] | ||||||||||||||||||||||||||
|
Hi tonymims, We're working on new implementations for Encoder and Decoder. These will allow users to register custom handlers for the encoding and decoding process of specific types. The new encoders and decoders will also be able to handle the base types as defined by reflect.Kind. This should solve the problems in this ticket. You can follow the progress of the new implementation by watching Thanks, Kris | ||||||||||||||||||||||||||
| Comment by tony [ 01/Aug/18 ] | ||||||||||||||||||||||||||
|
I have the same problem with a user-defined type pointing to an int as defined below:
Marshaling goes well, but Unmarshaling always sets the Val field to zero as the type of my field is not found in the switch/case statement decoding an int, in function getReflectValue from file bson/decode.go. For my case it could be fixed easily by adding a default at the end of the switch on containerType, and trying to convert the value to the real container type:
But I guess you would need to do that on a bunch of other place in the code. |