How to use querybuilder component's sql in query

Hi all! I’ve got a querybuilder component and would want to use it’s asSql property in a Postgres query. But SELECT * FROM table {{queryBuilder.asSql}} formats the asSql as a string, which creates invalid SQL. Any way to force placeholders to skip formatting and use them in place as is?

Alright @artman got a solution for you. The problem is most likely related to how we handle prepared statements. If you check this box in your resource’s settings, the .asSql property should start working as expected.

All of that being said, this component is pretty buggy right now, so keep us updated as how this goes.

Hey @justin - I have a similar issue where the Group By doesn't work when using a JS variable. But if I disable converting to prepared statements, the query returns no results.

More info here - Unable to Group By in MySQL using a variable


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
Screen Shot 2022-04-13 at 13.58.57