[GODRIVER-2119] Implement encoding.Text(Un)Marshaler for primitive.ObjectID Created: 06/Aug/21 Updated: 18/Aug/21 Resolved: 18/Aug/21 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Dylan Kozicki | Assignee: | Benji Rewis (Inactive) |
| Resolution: | Done | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Documentation Changes: | Not Needed | ||||||||
| Description |
|
In order to be able to use `primitive.ObjectID` as a map key, and have it marshal correctly into json, it needs to implement the https://pkg.go.dev/encoding?utm_source=godoc#TextUnmarshaler] interface, we use maps like these heavily in our product. |
| Comments |
| Comment by Benji Rewis (Inactive) [ 18/Aug/21 ] |
|
Thanks again for your contribution dkozicki@scoir.com! Your code should be available as part of the upcoming 1.7.2 release of the Go driver. |
| Comment by Githook User [ 18/Aug/21 ] |
|
Author: {'name': 'Dylan M. Kozicki', 'email': 'dylan.kozicki@gmail.com', 'username': 'Luberry'}Message: |
| Comment by Benji Rewis (Inactive) [ 10/Aug/21 ] |
|
Thanks for your report dkozicki@scoir.com! That seems like a reasonable use case; I’ll assign the team as reviewers to your PR, so we’ll all take a look. I’ve also filed a separate ticket GODRIVER-2124 to audit the primitive package and make sure we implement MarshalText and UnmarshalText for each type. That way, users can marshal from and unmarshal to maps with keys of any primitive type. |
| Comment by Dylan Kozicki [ 06/Aug/21 ] |
|
Here is my pr for this issue. |
| Comment by Dylan Kozicki [ 06/Aug/21 ] |
|
may also need to implement text marshaler as well, i'm currently writing a fix. |