25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(oracle): select schema after connection switch
t8y2b53f700dbea8
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vueindex c31ee5c92d..3ce53aa596 100644--- a/apps/desktop/src/App.vue+++ b/apps/desktop/src/App.vue@@ -44,6 +44,7 @@ import { resolveDefaultDatabase } from "@/lib/database/defaultDatabase";import { findTreeNodeById, resolveNewQueryTarget, resolveNewQueryInitialSql } from "@/lib/sql/newQueryContext";import { sqlObjectNavigationSourceKind, sqlObjectNavigationTableType, type SqlObjectNavigationTarget } from "@/lib/sql/sqlNavigation";import { buildExecutableObjectSourceStatements, executeObjectSourceSave } from "@/lib/table/objectSourceEditor";+import { schemaAfterConnectionSwitch } from "@/lib/schema/connectionSchemaInitialization";import { resolveExecutableSql, resolveExecutableSqlWithBackend, type SqlExecutionSnapshot } from "@/lib/sql/sqlExecutionTarget";import { uuid } from "@/lib/common/utils";import { isMacOS, isWindows } from "@/lib/backend/platform";@@ -1482,7 +1483,19 @@ async function changeActiveConnection(connectionId: string) {try {await connectionStore.ensureConnected(connectionId);const options = await getDatabaseOptions(connectionId);- queryStore.updateDatabase(tab.id, resolveDefaultDatabase(connection, options));+ const database = resolveDefaultDatabase(connection, options);+ queryStore.updateDatabase(tab.id, database);+ if (connection.db_type === "oracle") {+ try {+ // Oracle returns the session's current schema first; preserve that order before toolbar sorting.+ const schema = schemaAfterConnectionSwitch(connection.db_type, await api.listSchemas(connectionId, database));+ if (schema && activeTab.value?.id === tab.id && activeTab.value.connectionId === connectionId) {+ queryStore.updateSchema(tab.id, schema);+ }+ } catch {+ // Schema metadata failure must not turn a successful connection switch into a connection error.+ }+ }} catch (e: any) {toast(t("connection.connectFailed", {diff --git a/apps/desktop/src/lib/__tests__/schema/connectionSchemaInitialization.spec.ts b/apps/desktop/src/lib/__tests__/schema/connectionSchemaInitialization.spec.tsnew file mode 100644index 0000000000..e6e10b1d65--- /dev/null+++ b/apps/desktop/src/lib/__tests__/schema/connectionSchemaInitialization.spec.ts@@ -0,0 +1,12 @@+import { describe, expect, it } from "vitest";+import { schemaAfterConnectionSwitch } from "@/lib/schema/connectionSchemaInitialization";++describe("schemaAfterConnectionSwitch", () => {+ it("selects the current Oracle schema from the raw ordered result", () => {+ expect(schemaAfterConnectionSwitch("oracle", ["CONNECTED_USER", "APP", "SYSTEM"])).toBe("CONNECTED_USER");+ });++ it("does not initialize schemas for non-Oracle connections", () => {+ expect(schemaAfterConnectionSwitch("postgres", ["public", "archive"])).toBeUndefined();+ });+});diff --git a/apps/desktop/src/lib/schema/connectionSchemaInitialization.ts b/apps/desktop/src/lib/schema/connectionSchemaInitialization.tsnew file mode 100644index 0000000000..08a112f621--- /dev/null+++ b/apps/desktop/src/lib/schema/connectionSchemaInitialization.ts@@ -0,0 +1,6 @@+import type { DatabaseType } from "@/types/database";++export function schemaAfterConnectionSwitch(databaseType: DatabaseType | undefined, orderedSchemaNames: string[]): string | undefined {+ if (databaseType !== "oracle") return undefined;+ return orderedSchemaNames[0];+}diff --git a/apps/desktop/src/stores/__tests__/queryStore.multiStatementError.spec.ts b/apps/desktop/src/stores/__tests__/queryStore.multiStatementError.spec.tsindex 533dbdea70..ffd62bc684 100644--- a/apps/desktop/src/stores/__tests__/queryStore.multiStatementError.spec.ts+++ b/apps/desktop/src/stores/__tests__/queryStore.multiStatementError.spec.ts@@ -155,7 +155,10 @@ describe("queryStore multi-statement errors", () => {store.updateSchema(tabId, undefined);- expect(store.tabs.find((tab) => tab.id === tabId)?.completionContextVersion).toBe(1);+ expect(store.tabs.find((tab) => tab.id === tabId)).toMatchObject({+ schema: undefined,+ completionContextVersion: 1,+ });});it("preserves the selected statement's absolute editor range", async () => {