-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SinceID as Zero and omitempty #89
Comments
For scenarios where you need control over including e.g. an int64 field in your json output but still need it to be zero, the best way I've seen is making the int a reference in the struct and then set it to nil if you want to omit it or |
Ya that is how I'd get around that too is add a nil option. Changing it now would break existing code so if this route was taken it should probably be included in a new major version |
🤷♀ - you could make the backwards incompatible change and release it as a new major version. Should be an easy change for callers as long as it provides a convenience function |
Addressing this in #258 (by making SinceId a *uint64 ) |
* make AuthorizeUrl() return an error * NewClient now returns an error, MustNewClient can be used if a panic is acceptable * Address #89 - SinceID as Zero and omitempty * fix variable names * int64 --> uint64 * README.md
v4.0.0 was released - this should be fixed. |
Problem
SinceId is an int64 but the API documentation tells you to pass since_id=0 to work with paginated results. I found a problem in the smartcollections end point where it sorts by alpha title on default so in order to force an id sort you have to to use since_id=0 properly and have to initialize that param to force the id sort. With omitempty on SinceID the marshaler will consider this empty and not send the param even if you explicitly set it to int64(0) since obviously omitempty considers zero an empty int64 type. Also, if you don't set the param the struct will still initialize with zero and you dont want to pass since_id=0 ALL the time so you can't just remove omitempty.
Workaround
Initialize SinceID as int64(1) as it is basically the same thing for all intents and purposes but is not technically not what the api documents as the proper method and could trip up a developer.
Fix?
Possibly just document as a limitation on the struct field
The text was updated successfully, but these errors were encountered: