additionalScope does not resolve in PostgreSQL query

Hi there :wave:

I'm building a test app on the MongoDB MFlix dataset to showcase my collegues the power of Retool. However I encountered a potential bug passing additionalScope to a PostgreSQL query.

I trigger the a query with additionalScope from the success handler of another query.

It seems that the {{ids}} additionalScope does not get resolved in the PostgreSQL query. When inspecting the console you can see that the additionalScope actually gets passed to the query, but that it just doesn't resolve.

In other MongoDB queries the additionalScope seems to be rendering fine.

Any help is appreciated!

Hi @avr,

There is no bug, but the ids in the additional scope are being passed as strings within a string. Note the double quotes around the ids. You’ll need to get rid of the double quotes.

1 Like

just remove `.join(" '") may fix this issue.

Hi @mbruijnpff and @AnsonHwang :wave: Thanks for chiming in!

In the meantime I've been able to fix this and wanted to give an update on what exactly the issue was.

The main issue was that I should have used the ANY operator instead of the IN operator and pass the array of IDs to the additionalScope. After changing that, the query triggered successfully.


Screenshot 2023-09-13 at 16.25.16

The reason why I initially thought that there was a bug passing the additionalScope because the passed variable does not show in the query.

Thanks anyway for your help!