You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SQL Lab: keep the selected schema when switching to a database that has it
#45718
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
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
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.
All reactions