Hi, I am facing an issue where I want to dynamically add in a filter condition to a SQL statement eg. select * from table where {{filter_conditions}}
The filter conditions is then added via text input: So the text input would be something along the lines of "username = 'test' ". Then the query will execute "select * From table where username = 'test'".
Is there atleast a way to retrieve a list of all the shared queries from the query library inside a table on Retool?
This was my first attempt, display_name is a column within my table. Thought it would be possible to perhaps directly inject the text as a variable but its most likely coming through as a string so : Select * from users where "display_name='bob'", which is causing the issue, but im not entirely sure?
Would it be possible to store the {{queryBuilder.asSql}} value into a table, so I wish to save queries that the user builds and they can then retrieve and edit them? Is there a way to retrieve the query response as text and then convert it to a .asSql type? Inside a transformer maybe?
Can't test this atm but you should be able to just strore the .asSql value wherever and interpolate it in your query as long as you have the prep. statements disabled?!
Hi yes, you have been a massive help thank you so much!!! I was able to do this quite successfully with {{userGroupQuery.asSql.replaceAll('"','')}} just to convert it into a format that the sql DB could understand.
Is there a way to clear the query builder programmatically? I attempted to create an event handler on a button to control the queryBuilder but there are no available methods on the queryBuilder that allows me to clear its value? Is this perhaps a feature request?
@jhtester you can clear the query builder component programmatically by using a temporary state. you'd set the initial value of the query builder component to this new temporary state and each time you want to update/clear the query builder, you set the temporary states value to whatever you need. Notably, this is how we currently use the query builder to save historically predefined queries. simply replace the underlying QB object using the temporary state.
The query builder component does not seem to work with BiqQuery? Seems the asSQL is returning the BigQuery field name in quotes where BigQuery does not want quotes (in my example
the field name is channel)
It looks as though the double quotes around the column name in the generated SQL may be the issue here. You might try removing them using a bit of RegEx, does something like {{ queryBuiler1.asSql.replace(/"/g, "") }} work?
Typically the ? is a placeholder for a prepared statement in a query. You mentioned exploring this before but do you also have converting queries prepared statements disabled on the associated resource at the moment?