-
Goal: Set up a database connection that varies based on the environment selected.
-
Steps: It's possible, but is frustrating as it cannot transition between different modes in different environments properly while setting it up.
-
Details: See the screenshots. If i have an encrypted connection string for production environment, and then use the separate fields for the other environments, when I switch between environments they don't show the correct data, and often shows error messages.
In these series, it shows the original "production" appearance, with the encrypted connection string, then switching to "dev" it just shows empty fields. Switching to preview (from dev) works, and then switching back to "dev" will be correct, and finally, switching to "production" no longer shows correctly. The only way to restore the "production" UI seems to be to back out and reload the resource again. -
Screenshots:
Hi @Garr_Godfrey! What kind of resource is this? The built-in MongoDB resource looks a bit different when I'm setting it up. Unless you're on an older self-hosted instance? Regardless, I feel like the interface for configuring the resource should be consistent across environments and the fact that it isn't seems to be the source of this issue.
Can you confirm with version of Retool you're running and what kind of resource you're trying to set up?
This is not self-hosted, it is the cloud based version at retool.com, but the resource itself may have been set up a couple years ago.
however, the behavior has gone away. now when I switch between, I only get the connection string displayed for each environment, which is fine! I think it was maybe trying to be too smart before
i do have a somewhat related issue, but perhaps should open a new topic.
When using a connection like this across environments, the "query" in the app seems to have a couple different modes that are invisible and very difficult to change.
It has to do with the "selected database". When i add the resource and use the default database, it will switch appropriately with the environment. Each environment should use a different database.
But, if at some point we select a database in the query for it to use, it will no longer automatically switch. There is no visual indication of this, and getting it back to default is really challenging (I have to check "fx" to make it a function to get the database, then set it to blank, then uncheck "fx" and switch environments)
so an indicator to know/control if we are overriding the default database would be helpful on the query config.
Weird! I'm glad to hear it's working now.
To your second point, I'll definitely look into that and see if we can possibly set the database on a per-environment basis. In the meantime, would it work for you to keep it as a fx
field and use a ternary expression to set the database dynamically?