fix(schema): auto-select schema when creating query from schema context menu

When right-clicking a PostgreSQL schema node and selecting "New Query",
the schema dropdown in the editor toolbar was not pre-selected. Pass
node.schema to createTab so the editor initializes with the correct schema.
This commit is contained in:
t8y2
2026-05-23 12:33:14 +08:00
parent e62ad97bcd
commit 00fd206a57
2 changed files with 9 additions and 2 deletions
@@ -561,7 +561,7 @@ async function newQuery() {
await connectionStore.ensureConnected(node.connectionId);
connectionStore.activeConnectionId = node.connectionId;
if (node.database) {
queryStore.createTab(node.connectionId, node.database, undefined, "query");
queryStore.createTab(node.connectionId, node.database, undefined, "query", node.schema);
return;
}
const connection = connectionStore.getConfig(node.connectionId);
+8 -1
View File
@@ -111,7 +111,13 @@ export const useQueryStore = defineStore("query", () => {
return tabs.value.find((t) => t.connectionId === connectionId && t.database === database && t.title === title);
}
function createTab(connectionId: string, database: string, title?: string, mode: QueryTab["mode"] = "query") {
function createTab(
connectionId: string,
database: string,
title?: string,
mode: QueryTab["mode"] = "query",
schema?: string,
) {
if (title) {
const existing = findTabByTitle(connectionId, database, title);
if (existing) {
@@ -126,6 +132,7 @@ export const useQueryStore = defineStore("query", () => {
title: title || `Query ${tabs.value.length + 1}`,
connectionId,
database,
schema,
sql: "",
isExecuting: false,
isCancelling: false,