[GODRIVER-305] reflection panics when doing equality comparisons Created: 24/Mar/18 Updated: 28/Oct/23 Resolved: 09/May/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | 0.0.2 |
| Fix Version/s: | 0.0.4 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sam Kleinman (Inactive) | Assignee: | Kristofer Brandow (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | FreeMonitoring, evg | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
https://github.com/mongodb/mongo-go-driver/blob/master/bson/encode.go#L466 changing this line to use reflect.DeepEqual() rather than == fixed things for me, but I think normal equals should be fine. |
| Comments |
| Comment by Kristofer Brandow (Inactive) [ 24/Apr/18 ] |
|
We're going to add add bson.Zeroer, |
| Comment by Sam Kleinman (Inactive) [ 24/Apr/18 ] |
|
Sorry for not following up on this earlier. What's the outcome/plan for doing this? |
| Comment by Kristofer Brandow (Inactive) [ 11/Apr/18 ] |
|
Ah, yeah we don't have it yet, I will add it in the next round of BSON library updates. |
| Comment by Thomas Delacour (Inactive) [ 11/Apr/18 ] |
|
So has the decision been made to not use DeepEqual? Also, could you point me to bson.Zeroer? I can't seem to find it in the godoc. |
| Comment by Kristofer Brandow (Inactive) [ 05/Apr/18 ] |
|
For this we might be better served with an implementation like this: https://github.com/golang/go/issues/11939. The main reason I don't want to use reflect.DeepEqual is because it traverses into private properties and in some cases values aren't equal to themselves which could cause some inconsistent behavior. If users want to omit an empty struct then they'll need to make it a bson.Zeroer or whatever we call it. |
| Comment by Kristofer Brandow (Inactive) [ 26/Mar/18 ] |
|
Can you provide the panic stack trace? |