Display bug setting up database resource

  • 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. :thinking:

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.

1 Like

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

1 Like

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. :sweat_smile:

To your second point, I'll definitely look into that and see if we can possibly set the database on a per-environment basis. :thinking: 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?

to be clear, it does work on a per-environment basis because the default database can be specified in the connection string. We use it all the time, but then the setting gets overloaded and it stops working for a specific query. Just, the way it visibly displays it, we cannot tell the difference whether it is using the default from connection string or overriding it.

and we have 4 environments. We actually sometimes override it and we have the retool environments match our db name, so we can do it using fx and db_{{ retoolContext.environment }}
But that forces us to use fx on the collection name as well and that can be error prone.

1 Like

Got it. :+1: I think I have enough context to attempt a reproduction of this behavior.

One thing I'd like to clarify - are you saying that you are forced to dynamically set the collection name, as well, because the dropdown otherwise doesn't auto-populate? What kind of errors do you run into with this implementation?

1 Like

No, if we don't touch it, it works fine. But when someone breaks it, it is an invisible breakage.

I am assuming the database is undefined by default, and the UI is showing the default database in this case. As soon as we type in the field, the query now has that database set and overrides the default

Occasionally, we accidentally click in the field where the database is set, and maybe hit backspace key. At that point, it stops automatically switching. We put it back to what it was, but now it is viewed as overriding the default database and it won't switch based on environment.

Ideal solution would be something like, the field displays placeholder text if the database isn't actually specified in the query, or a checkbox to set it to use the default. A visual indication that it is using the "default" database vs the database name displayed would be really helpful.

1 Like

Ah this really condenses the issue down into something that I think we can take action on! I'll take this feedback to the team and let you know as soon as I have any updates. :+1:

2 Likes