Why is query.trigger not using new values of additional scope variable?

Not sure why when I run the JS script the second time, the value from last run is still stored as table name in the additional scope.

So first run shows table name as 'shift_segments_tmp_nb....' and second run shows it stored again but table name should be 'shift_segments_tmp_dv....' instead.

The first time I ran the JS script I selected 'shift_segments_tmp_nb..' and the second time I ran it I selected 'shift_segments_tmp_dv..' from the table.

It could be a problem of synchronisation.
I believe that the trigger() function returns a Promise and you need to work with them properly.
I would try to isolate the problem in a separate query and call it like this:

await query_if_table_exists.trigger( {... scope1 } );
await query_if_table_exists.trigger( {... scope2 } );
1 Like

Using 'await' fixed another issue I have. Thanks!

I think this error is probably what is causing my issue of the 'result' variable not getting the correct value. But I am not sure what is causing the error.

This is the SQL for 'qry_if_table_exists':

select tablename
from pg_catalog.pg_tables
where tableowner = 'prod_admin' and "tablename" = {{tableName}}

@ricky-raven does that postgres resource have prepared statements disabled in the resource setup, to allow SQL injection like this?


Yes, it is disabled.