fix(query): sync open executors after default database edit

This commit is contained in:
Melody Ruch authored and GitHub committed 2026-09-29 21:26:17 +08:00
1 parent c8aed1b6e5
commit edd2592869
3 files changed
+108

No files matched your search

+15
View File
@@ -5537,6 +5537,20 @@ export const useQueryStore = defineStore("query", () => {
persistSavedSqlExecutionTarget(tab, options);
}
/**
* Editing a saved connection's default database (Connection dialog Save) only
* updates the connection record — tabs opened before the edit keep whatever
* database was snapshotted onto them at creation time (issue #7905). Re-point
* every open tab that was still on the connection's old default over to the
* new one, same as if the tab had just been created fresh.
*/
function syncTabsDatabaseForConnectionEdit(connectionId: string, previousDatabase: string, nextDatabase: string) {
if (previousDatabase === nextDatabase) return;
for (const tab of tabs.value) {
if (tab.connectionId === connectionId && tab.database === previousDatabase) updateDatabase(tab.id, nextDatabase);
}
}
function updateCatalog(id: string, catalog: string | undefined, database: string, options: UpdateExecutionTargetOptions = {}) {
const tab = tabs.value.find((candidate) => candidate.id === id);
if (!tab || (tab.catalog === catalog && tab.database === database)) return;
@@ -9489,6 +9503,7 @@ export const useQueryStore = defineStore("query", () => {
reorderTab,
createExecutionTargetGuard,
updateDatabase,
syncTabsDatabaseForConnectionEdit,
updateCatalog,
updateSchema,
updateConnection,