[GODRIVER-410] IsZero and structs Created: 08/May/18 Updated: 17/May/18 Resolved: 17/May/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 0.0.5 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Thomas Geulen | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
It is currently not possible to flag a struct, i.e. time.Time as 'omitempty' because IsZero() return false, due to the missing Zeroer implementation. Should IsZero also check if the given value is equals to the default value of the struct instead of return false in case of a non-implemented Zeroer interface? |
| Comments |
| Comment by Githook User [ 17/May/18 ] |
|
Author: {'email': '38960709+thomasgeulen@users.noreply.github.com', 'username': 'thomasgeulen', 'name': 'Thomas Geulen'}Message: Merge branch 'master' into |
| Comment by Githook User [ 17/May/18 ] |
|
Author: {'email': 'thomas.geulen@csb.com', 'username': 'thomasgeulen', 'name': 'Thomas Geulen'}Message: |
| Comment by Kristofer Brandow (Inactive) [ 15/May/18 ] |
|
Code Review: https://github.com/mongodb/mongo-go-driver/pull/54. |
| Comment by Kristofer Brandow (Inactive) [ 10/May/18 ] |
|
Hi thomas.geulen, So the time.Time type does implement a bson.Zeroer, however, the place where we check for zero is after we have already encoded the time.Time value. You fixed this for checking for empty before inline, but it looks like we didn't move the check for omit empty up high enough. If you'd like, send another PR and move the omitempty isZero line to here: If you don't have availability to do so, let me know and I'll add it to our backlog. Thanks for the bug report! --Kris |