Bug? Function currently used in workflow is not the function I see in the editor

Hi,

I got a very strange result in my SQL workflow query that uses the function below (without the first line: return 'test' of course).
It appears that when I change the code in the function, the output of the function changes accordingly, but in my SQL query the function does not use that output.
When I added "return 'test' " in the first line the output is "test". No problem.
As you can see here:

However, when I use the function in the select statement like this:


you will see that the function returns something completely different.
It seems that the actually used function is not what I see in the editor.

A related problem could be that when I define a new function and want to use it in a query, I get the errror "function does not exist".

Can anybody help me?

Hi @Reyer_Sneller,

You're right to question that behavior — the issue is likely due to mixing up environments.

The get_domain function you created in Retool is a JavaScript function, but when you run: SELECT get_domain('abcde'); you're asking PostgreSQL to run a SQL function with that name. Unless you've defined a SQL version of get_domain in your database, this won't work as expected.

To test your JavaScript version, run: get_domain('https://www.aaa.com/abc') ...in a JS Query block, not SQL.

Let me know if you need help with fitting this into your workflow.

Hi @ Shawn_Optipath,

YES! You are absolutely right.
I didn't realize that get_domain in an SQL query should be and SQL function.
And yes, there was a get_domain function in the database.
Fixing a small problem in that function solved my query problem.
This proves once again that I am not an experienced developer. But thanks to your help I can move on.
Have a good Easter weekend
regards Reyer,
from The Netherlands

Hi @Reyer_Sneller,

I'm glad I was able to help you find the solution. There is always someone around here to help.

Thank you, and I hope you have a fantastic Easter weekend as well.

Shawn