Trouble Getting Search Bar Working

I seem to have something wrong in my where statement where I reference the textinput box as a search bar. If I run with anything in the search box, it works perfectly fine. That leads me to believe the !trxtypeFilter part of the where clause is working fine. It doesn't like the % or the quotes. It seems correct to me.

FYI - I did click "enable snake skin" for sql queries when I first set this up. I also have prepared sql disabled. I am querying a table which was created via csv upload. Right now the table is the only source of the query. I will be adding other sources shortly.

Can anyone tell me what I'm doing wrong? I get the below message currently.

datasource run failed.
** * message:"syntax error at or near "%""*

t.trx_type, t.timestamp,t.desc,t.asset as token,t.qty,t.qtyt.spot_price as histval,'usd' as feecurr,t.fees,(t.qtyt.spot_price) + t.fees as cost
WHERE ({{!trxtypeFilter.value}} OR trx_type ILIKE {{'%' + trxtypeFilter.value + '%'}})
ORDER BY token, timestamp DESC;

Hey @bigshooTer!

That query looks like it's set up correctly for having prepared statements turned on, I'm curious to see what the result is when you run it in that case since it's a bit more secure.

If you really want to have them turned off though, you might try using {{"'%" + trxtypeFilter.value + "%'"}} so that the filter value is correctly wrapped by single quotes in the resulting query.

Let me know what you find!

1 Like

I’m not sure what happened but this wouldn’t work yesterday. Now it does. I’ll take it though. I was getting discouraged but onto the next item now. Thank you

1 Like