Hi Mrts. Redash,

I get an error after created the query

this is the query used:

SELECT t1.TABLE_NAME AS tabla_nombre, t1.COLUMN_NAME AS columna_nombre, t1.COLUMN_DEFAULT AS columna_defecto, t1.IS_NULLABLE AS columna_nulo, t1.DATA_TYPE AS columna_tipo_dato, COALESCE(t1.NUMERIC_PRECISION, t1.CHARACTER_MAXIMUM_LENGTH) AS columna_longitud, PG_CATALOG.COL_DESCRIPTION(t2.OID, t1.DTD_IDENTIFIER::int) AS columna_descripcion, t1.DOMAIN_NAME AS columna_dominio FROM INFORMATION_SCHEMA.COLUMNS t1 INNER JOIN PG_CLASS t2 ON (t2.RELNAME = t1.TABLE_NAME) WHERE t1.TABLE_SCHEMA = 'public' AND t1.table_name ='{{table_name}}' ORDER BY t1.TABLE_NAME;

however, after using the “Format Query” button and passing the parameter the string “queries” again, it works.

Here is the api call that I am making from ansible:

variables

json

I haven’t used ansible but I think the problem is how it formats the parameter marker. I’m looking at the final line of the first image you shared

AND t1.table_name = '{{'{{'+'table_name'+'}}'}}' ORDER BY t1.TABLE_NAME;

I think the double-curly braces ({{}}) are the problem. Does this syntax allow for escaping like this?

AND t1.table_name = \{\{ table_name + \}\}  ORDER BY t1.TABLE_NAME;

Thank you for your prompt response, for the output you see below, this type of escape is not allowed in ansible:

1 Like

Seems like you can avoid escaping the curly brackets entirely with the guidances from this thread. Just use a {% raw %} block.

for these cases the following escape is used, but the api call does not run

"character"

error

Thank you for your prompt response, i is testing.

I don’t understand, where should I place this scape if in the json the api call or in the query parameter.

json

or here

I would wrap the entire query contents to be on the safe side. Although I haven’t used Ansible so this might not be best practice.

I understand, I ask you something else, is there any way to make an api call using this function?

image

for once the query is created, I can refresh and sort the query.

Solved

I add the following parameters in the options section into json the api call:

“options”: {

"parameters": [

  {"name": "table_name", "title": "table_name", "global": false, "value": "queries", "type": "text", "locals": []

  }

]

thank you Jessie

1 Like

Glad you figured this out! You did all the work :smiley:

1 Like