External variables in SQL Statement Previews are incorrect

Hello Retool Community!

I've been encountering an issue where external variables in my SQL statements are not appearing correctly in my SQL Statement previews. That is, my SQL statements are not being rendered as prepared statements in the previews, event though they work as intended when I actually run the query.

In the first screenshot, "ADAIR" is coming from a select field in my dashboard. The issue is

ADAIR

should actually be

["ADAIR"]

Screenshot 2024-04-03 at 10.58.36 AM

When I hover over the variable in the query, it shows the correct value.

unnamed

I had previously checked the "Disable converting queries to prepared statements" option for this query's resource, then unchecked it later. It seems the SQL statement preview still thinks that option is checked. Toggling this option back and forth does not fix this issue.

My queries work as intended (i.e. ["ADAIR"] is used in the query), but this gets in the way of troubleshooting my queries. I would like to copy the query and tinker with it outside of Retool, but this becomes an obstacle.

Any help here would be greatly appreciated!

Hi @kalebts ,

Yes, currently for the SQL Statements, the preview doesn't show the "Prepared statement" version. It's best to run the query to test whether it works.

I would like to copy the query and tinker with it outside of Retool, but this becomes an obstacle.

Sorry, there isn't an easy way to do it right now. With prepared statements it will even look worse. It'd look something like:

with selected_geographies as (
  select *
  from unnest($1) as geog
), ...

and then the value (["ADAIR"]) passed in as an argument.