Evaluated expression from bulk insert working in DB but not via Retool interface

Hi there - I'm trying to do a bulk upsert on a postgres DB, which then returns various rows from the upserted data.

The following query in Retool is throwing an error when run; however, when I execute the query.evaluatedExpression inside the DB itself, it performs the operation correctly.

I have a feeling it's related to the way I'm inserting code2.data any maybe needing to use the formatDataAsArray method, but I've tried a few variations of that to no avail.

What am I doing wrong here?

I adjusted my approach to side-step prepared statements, and also disabled prepared statements on the Resource itself. However, after running the query, the resource is still indicating that prepared statements are being used, even though I disabled the checkbox...?

Seems like there may be a bug or larger issue happening with the prepared statement functionality?

Error in converting query to prepared statement. You can disable this feature by checking the 'Disable converting queries to prepared statements' checkbox on the resource configuration page

SS 2025-01-24 at 3.04.37 PM

I figured out the issue with disabling the prepared statements. I was doing it on the production env but not the staging env.

I assume the first issue I was running into has to do with the prepared statements, but I figured an alternative method. This should suffice for now!

Yes, @bryantaxs you're correct that passing in a query from Javascript is prevented with prepared statements enabled. Generally, you want to limit the amount of sql wrapped in double curly brackets if you want to use prepared statements, and you cannot have dynamic names or actions (e.g., a column name, a table name, or SELECT ).

Glad you have a path forward!