Add OptionalNullable<T>
?
#6308
Labels
needs-triage
Workflow: This is a new issue that needs to be triaged to the appropriate team.
OptionalNullable<T>
?
#6308
Non-nullable optionals should be
Nullable<>
- to distinguish between "not set" vs""
(strings) /0
(ints),[]
(arrays).That distinction allows customer to express any value, without sacrificing anything. When
!HasValue()
, we don't send the value.With non-optional nullables, everything is also
Nullable<>
, the only difference is that when nullable has no value, we serialize it asnull
(at least, in JSON body context; I don't remember exactly how paths/query params/headers behave - that's ok, that's beyond the point).And finally, if there is an optional nullable, then we have two options:
Nullable<T>
, "not set" = do not send, "has value" = send value. This won't allow users to sendnull
values, but maybe it is practical enough.Nullable<T>
, "not set" = sendnull
-- I don't think it is the right approach to optionals.Nullable<Nullable<T>>
,options.Property.HasValue() == false
= do not send,options.Property.HasValue() == true && options.Property.Value().HasValue() == false
= sendnull
;options.Property.HasValue() == true && options.Property.Value().HasValue() == true
= sendoptions.Value().Value()
. This would be an implementation that allows to accurately represent any value, but it is most likely too complex to be used by humans. I think we should implement option 1, and if we ever encounter a need for the service to distinguish betweennull
and lack of value sent in this case, we work with the service team, or we should put some other solution (i.e. something like item 4 below).OptionalNullable<T>
, which has methods for bothHasNonNullValue()
andIsNull()
(and does not haveHasValue()
to avoid confusion withNulable<T>
). To set null values, we addoperator=(std::nullptr_t)
/OptionalNullable<T>(std::nullptr_t)
.The text was updated successfully, but these errors were encountered: