Hi there -- I can't find anything exactly like this on the forum, so hopefully it's not a repeat!
I'm using a Snowflake table and the table has a number of boolean columns for filtering records.
CREATE TABLE my_table (
id INT,
name VARCHAR,
is_red BOOLEAN,
is_big BOOLEAN,
is_happy BOOLEAN
);
(There are actually many boolean columns, but kept it simple for the example.)
I have a set of filters on my page that can be switched on and off by different user actions. It collects a list of columns, like: ["is_happy","is_red"].
Whenever this list changes, I trigger the query to refresh the data based on the filters.
Expected result is:
select
a.*
from
prj_jynarque_ps_dev.jyn_tableau_dashboard_pivot a
where
**"IS_HAPPY" or "IS_RED"**
The above is tested ok when run as a query directly on Snowflake, so I know it is supposed to work.
I tried a number of approaches, but the simplest is this one:
{{
I2A1.filtered_insights.map(
(x) => {
return(`"${x}"`)
}
).join(" or ")
}}
This results in this: ""is_happy" or "is_red"". Notice the extra double quotes.
Other things I tried, like converting the boolean columns to one json column and using syntax like:
{{
I2A1.filtered_insights.map(
(x) => {
return(`get(insight_flags, '${x}')::boolean = true`)
}
).join(" or ")
}}
failed because of the same extra quotes issue.
I understand that the Query Builder can be used in some way to get around this issue, but my interface doesn't use that component, so I'm at an impasse. I can just hard code all of the fields in the sql, but I'm hoping to not do that because I expect these flags to grow and I'd rather have one less place to hard code things.
Thanks for any suggestions!