-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Open
Description
Today to make a parameter optional, the user needs to have a workaround in the query logic itself. For example:
select count(0)
from queries
where 'All' = '{{org_id}}' or org_id::varchar = '{{org_id}}'
In this case when the value of org_id
is All
, then we don't filter by it. It will be great if the user could mark a whole section as optional if no parameter is provided. The templating language we use (Mustache) actually supports this:
select count(0)
from queries
{{#org_id}}
where 'All' = '{{org_id}}' or org_id::varchar = '{{org_id}}'
{{/org_id}}
If no value for {{org_id}}
is provided, then the section between {{#org_id}}
and {{/org_id}}
won't be rendered. So in theory, we can just allow for passing empty values for parameters and it works.
This has two issues though:
- Any false-y value will make this section not render. Including
0
(zero), which might be acceptable in some cases. - This might make the implementation of Move parameters merging to the backend and make it safe #2904 more complicated.
We should probably take this into account when implementing #2904, and revisit once it's indeed implemented.
timc13, ariarijp, gabrieldutra, barbara-sousa, divyanshu-narayan and 85 morekykrueger, franccesco, steexx, shubhamgoyal41, ioah86 and 7 more