-
Notifications
You must be signed in to change notification settings - Fork 80
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
Represent "meaningful null
"
#2049
Comments
This has come up in the .NET world often too and while we offer workarounds the Developer Experience has never been great. +1 modelling this explicitly. In .NET I would still model this explicitly as This is also an issue with the Update API where people may use Since the update doc is userdefined there is nothing we can spec for it but something to consider in this context too. |
I think its important we keep the distinction between
TLDR: I really like the |
++ To introduce a way to distinguish this in the spec. I've avoided generating endpoints to update index settings at the moment, as I didn't have a way to identify this nuance without coding something into my generator. I have a local branch with essentially what @Mpdreamz suggested that I was considering as a way to support source updates with explicit nulls to remove fields. The same type could serve this purpose for "resettable" properties. I'm also wondering if we need to consider explicitly splitting the type used for, say, index settings, where the type used in requests includes the chosen representation to allow resetting a value by sending null but where the response type uses a more standard type since the properties will either be set or potentially null/optional. For .NET, this would make consumption of GET index settings easier since we'd avoid wrapping properties as a I'm leaning towards |
Since we know that the server team will be taking over updating the spec in the future, I'd like to go with the explicit approach which forces a choice over how code generation should handle
|
These keys allow using an explicit `null` as the value to "unset" the configuration when merging multiple component templates. As related to the merging tables seen in elastic/elasticsearch#95979 (comment) Relates also to the discussion in elastic#2049
These keys allow using an explicit `null` as the value to "unset" the configuration when merging multiple component templates. As related to the merging tables seen in elastic/elasticsearch#95979 (comment) Relates also to the discussion in elastic#2049
[edit 2023-04-03 - rewritten to explain "semantic null" and provide several proposals]
Some fields in the settings API handle
null
values differently from missing values: sendingnull
resets the setting to their default value, whereas omitting the field just keeps the current value.We already use
SomeType | null
in the spec for fields where ES can returnnull
for missing or unknown values. Semantically these are optional values where the ES server doesn't have aif (value == null)
test before serializing the field. We added these| null
mainly to allow validation tests to pass, even if semantically speaking they should not be there.We need to distinguish "semantic null" from "null-as-optional".
There are different ways to represent this in the spec:
Follow the example of
Stringified
to represent non-string values that ES can sometimes serialize as strings, and introducetype OptionalNull<T> = T | null
:SomeType | null
.SomeType | null
withOptionalNull<SomeType>
.Consider that semantic null is important enough to have its own type defined as
type NullValue = null
:SomeType | NullValue
SomeType | null
as is.Consider that the
null
value is an encoding concern and that it's really about default values:SomeType | Default
wheretype Default = null
SomeType | null
as is.Note: we can also consider
Reset
instead ofDefault
but this name implies some action rather than a value or state. It makes sense for a request value but not so much for a response value.Something else?
The text was updated successfully, but these errors were encountered: