Changing schema depending on Environment

My production data is in a schema "developed", and my test data is in a schema "test", they are in the same resource connection. I want to use the switch environments feature such that when the environment is production, use the developed schema, and when it is staging, use the test schema.

my query is as follows:

select * from {{retoolContext.environment === 'production' ? 'developed' : 'test'}}.indication;

this works when the environment is in production but not when it is in staging, where i get the error "syntax error at or near "$1"". The {{}} is indeed computing 'test'.

And is there a way to get the GUI mode to select the schema dynamically?

Hey @Ashton_Teng! Just to double check, do you have Prepared Statements disabled for this resource?

For your second question, this isn't currently supported directly in the query's GUI mode. I'll create a feature request for this now though!

Unfortunately since my app uses a mix of direct SQL statements and GUI mode, it would be useless to have the prepared statements on without the feature request. Thanks for filing it, could you let me know if this comes online so I can update the self hosted version? thanks!!

Ah, definitely valid + will do! :slight_smile: