Can I access the plain SQL query generated by Retool that will be passed to my db?
There is a query.query attribute but this has been blank/null in the examples I've tried to produce.
The use case is to save the prepared SQL (e.g. for an update statement) and then run it later optionally.
Hi Jack! The query.query attribute should contain the string version of the SQL query that you wrote, as long as that query has been saved. I was able to produce a very simple example. Those things might get more complex as you move to a more complicated query.
1) You must disable prepared statements. I don't believe you'll be able to achieve the functionality you want with them enabled. You can read more about why here:
2) I created a temp state variable that will hold the value of the query.query attribute and ran another JS query to set the value of that temp state variable.
3) Then created another SQL query that pulls the value from temp state. This is the step where I believe that having prepared statements enabled would cause this setup to fail.
Hope this helps!