Prepared statements error with query builder component

Hi,

I am also struggling with the Query Builder and Postgres Resource.

  1. Disable converting queries to prepend statements is unchecked on the resource
  2. I have used replaceAll to sanitize the query.

This is my query:

select * from audit."Audit" {{auditQueryBuilder.asSql.replaceAll('"','').replaceAll("\n",'')}};

where auditQueryBuilder.asSql.replaceAll('"','').replaceAll("\n",'') is

WHERE "service" = 'ACCOUNTING'"

Which results this error:

message:"syntax error at or near "$1""

I've attached a partial payload for the http request

I'm getting the same error

I'm getting it because I didn't select "save changes" when I went in to edit my settings for disabling prepared statements.

Hey @ryliev!

To be clear, you're looking to use the Query Builder in a Query JSON as SQL query, but the query itself is running into syntax issues. Do you have prepared statements currently enabled or disabled?

I wonder if this somewhat out-of-the-box option would work for you—it uses the alasql library and a Javascript query. If you import the alasql library as an app library, you can then reference the query builder inside the JS query like so:

const data = query1.data

const query = "select * from ? " + queryBuilder1.asSql.replaceAll('"', '')

return alasql(query, [data]);

Let me know if you have any questions!

1 Like