Query is not working across environments

Hey Retool Community,

I wrote a query (let's call it Query1) to get suppliers from my database. Query1 is working perfectly fine in the production environment, but whenever I switch to my staging or dev environment, it is not working anymore. This is Query1, and the error message I get when I run the query in either stage or dev:

I think this is extremely weird, as it should work across the environments as the database is identical across all environments. When I rewrote the query a bit (let's call this new query for Query2), it is now working in stage and dev, but it is no longer working in the production environment. See this picture for Query2 and the error message that appears when connected to production:

I tried to make a new test environment, where I used the schema migration in the database to populate the tables. I migrated from the production environment database to the test, and thought that Query1 should work fine for this new environment. However, Query1 is not working for the test environment, and Query2 is working for the new test environment.

As the queries are able to fetch data from the database for some environment I don't believe that it is something wrong with the queries itself. This makes me believe that there is something wrong with my environments.

Has anybody experienced something similar before? Is there someone working in Retool that can have a look at my app and see what wrong?

I would really appriciate it :smiling_face:

BTW: If I remove the part of Query1 and Query2 for searching in the database, it is working across all environments. Can this have something to do with the complexity of the query?

Hi @Molly,

Very strange, have you tried going to your DB Resource in the resource tab, flipping through the different environments, and seeing if anything is different? First thing that came to mind was maybe you've got this feature enabled in some of them?

image

have you tried using CONCAT(string1, string2...) instead of the || operator? there is a difference here unfortunately, concat() ignores null whereas the || operator returns null so this might not be an option for you

Unlike the concatenation operator || , the CONCAT function ignores NULL arguments.

source

1 Like