GitHub user shaoyinz created a discussion: SQL Lab: keep the selected schema 
when switching to a database that has it

**Is your feature request related to a problem?**
We have one Superset database connection per environment (dev, stage, prod) for 
the same Postgres application, and every environment has the same schemas. In 
SQL Lab, when I switch databases in "Select Database and Schema", the schema I 
had selected is cleared. I have to pick it again every time, even though the 
new database has a schema with exactly that name.

**Describe the solution you'd like**
When the database changes, keep the selected schema if the new database has a 
schema with the same name, and clear it only if it doesn't. DatabaseSelector 
already does this check when the schema list loads (the useSchemas onSuccess 
handler), but changeDatabase() clears the schema before that check runs.

**Describe alternatives you've considered**
- One SQL Lab tab per environment, each with its own database and schema.
- Schema-qualifying every table name in queries.

Both work, but switching environments to compare results is a routine task, and 
the reset adds a step every time.

**Additional context**
The same DatabaseSelector is used when creating datasets, where keeping the 
schema would help too.

**Are you willing to contribute?**
Yes. I can open a PR with tests and a before/after recording.

GitHub link: https://github.com/apache/superset/discussions/45718

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to