Closed jo-asplin-met-no closed 1 day ago
As long as all int64 metadata fields are required, we don't need to worry about this. In particular, a client using GetObservations() doesn't need to distinguish between unset and explicitly set to zero value. Once we add an optional int64 field, we need to support this distinction.
If you use PutObservations to insert observations for time series associated with levels -1, 0, and 1, then the level field will not appear in the response for the time series level 0. This is essentially related to how the reflect package in Go considers default values as unset even if you explicitly set it (using reflect.Value.SetInt()). One way to fix this is to represent the metadata field as *int instead of int (i.e. effectively getting a "nullable" type). Another approach is to handle default type values as a special case, e.g. by making use of reflect.Value.IsZero() etc.
How to reproduce:
First insert observations for the three time series (level -1, 0, and 1):
Then try to get data for levels -1, 0, and 1, and see that we only get data for -1 and 1:
And indeed that we get nothing at all when asking for just level 0:
Also observe that in the database the level 0 is there as expected: