Replies: 1 comment 2 replies
-
|
I'm not sure about this one. The idea of Similarly, I think the |
Beta Was this translation helpful? Give feedback.
-
|
I'm not sure about this one. The idea of Similarly, I think the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Currently provider doesn't support
nilvalues, which sometimes leads to weird hacks in the client code.For example, suppose that we're shipping metrics to an external service. The URL of this service is provided via a config parameter. Now, on some deployments (e.g. private sandboxes used by individual developers), we don't want to send the metrics.
Currently there are two ways of handling this.
The first one is to use a single parameter, and a hardcoded "nil substitute". E.g. if the param value is
http://do-not-send-metricswe don't ship the metrics. This is weird and hacky. Chosing a nil substitute may not be possible for all types (e.g. dates or numbers).Another option is to introduce another param, a boolean, called e.g.
ship_metrics. The downside here is that we now need an extra param, and we still need to provide some dummy value for the URL.If
nilwas supported this could easily be handled with a single param. If the param is nil, don't ship metrics.Solution proposal
We add the
nil?option, so one can do:In this case, if the value is not provided, it will default to
nil. If the provided value is an empty string, the param is cast tonil. This behavior can be changed by providing anempty_valuesoption, which would work like in Ecto changeset. The question is whether this option should be param-specific, or is it enough that it's global (i.e. single setting for the entire schema).By default, params are not nilable.
Beta Was this translation helpful? Give feedback.
All reactions