[GODRIVER-1011] Struct decoder only works for lowercased fields Created: 30/Apr/19 Updated: 28/Oct/23 Resolved: 05/Sep/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | 1.1.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Divjot Arora (Inactive) | Assignee: | Divjot Arora (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
If no struct tags are provided, the struct decoder will only work if the lowercased struct field name matches the BSON key. This doesn't work for camel-cased fields. For example, if the BSON key is "firstBatch", the struct decoder will not find it in the struct because it is looking for "firstbatch". Filing this as a question ticket because I'm not sure what we want the behavior to be. At the very least, we should document this behavior and encourage users to always use struct tags. |
| Comments |
| Comment by Githook User [ 05/Sep/19 ] |
|
Author: {'name': 'Divjot Arora', 'username': 'divjotarora', 'email': 'divjot.arora@10gen.com'}Message: Change struct decoder to be case-insensitive. Change-Id: I31674da7af7405f659dbbe7d0aaeeadca7fdb946 |
| Comment by Githook User [ 05/Sep/19 ] |
|
Author: {'name': 'Divjot Arora', 'username': 'divjotarora', 'email': 'divjot.arora@10gen.com'}Message: Change struct decoder to be case-insensitive. Change-Id: I31674da7af7405f659dbbe7d0aaeeadca7fdb946 |
| Comment by Divjot Arora (Inactive) [ 04/Sep/19 ] |
|
CR: https://review.gerrithub.io/c/mongodb/mongo-go-driver/+/467447 |
| Comment by David Golden [ 30/Apr/19 ] |
|
encoding/json says:
We should match that behavior as that will be users' default expectation. |