Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix(oceanbase-oracle): initialize current schema on connection switch

efeire6f0c84556a43
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index 12db0efada..2b97dfac73 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -3404,9 +3404,9 @@ async function changeActiveConnection(tabId: string, connectionId: string) {
queryStore.updateDatabase(tab.id, database);
isCurrentTarget = queryStore.createExecutionTargetGuard(tab.id);
if (tab.externalSqlPath) rememberExternalSqlFileTarget(tab.externalSqlPath, { connectionId, database, catalog: undefined, schema: undefined });
- if (connection.default_schema || connection.db_type === "oracle") {
+ if (connection.default_schema || connection.db_type === "oracle" || connection.db_type === "oceanbase-oracle") {
try {
- // A configured default wins. Otherwise Oracle returns the session's current schema first.
+ // A configured default wins. Otherwise Oracle/OB returns the session's current schema first.
const orderedSchemas = connection.default_schema ? [] : await api.listSchemas(connectionId, database);
if (!isCurrentTarget()) return;
const schema = schemaAfterConnectionSwitch(connection.db_type, orderedSchemas, connection.default_schema);
diff --git a/apps/desktop/src/lib/__tests__/schema/connectionSchemaInitialization.spec.ts b/apps/desktop/src/lib/__tests__/schema/connectionSchemaInitialization.spec.ts
index 1ea79c96fd..979f3095ce 100644
--- a/apps/desktop/src/lib/__tests__/schema/connectionSchemaInitialization.spec.ts
+++ b/apps/desktop/src/lib/__tests__/schema/connectionSchemaInitialization.spec.ts
@@ -2,16 +2,16 @@ 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.each(["oracle", "oceanbase-oracle"] as const)("selects the current %s schema from the raw ordered result", (databaseType) => {
+ expect(schemaAfterConnectionSwitch(databaseType, ["CURRENT_OWNER", "LOGIN_USER", "APP"])).toBe("CURRENT_OWNER");
+ expect(schemaAfterConnectionSwitch(databaseType, [])).toBeUndefined();
});
it("does not initialize schemas for non-Oracle connections", () => {
expect(schemaAfterConnectionSwitch("postgres", ["public", "archive"])).toBeUndefined();
});
- it("prefers a configured default schema for PostgreSQL and Oracle", () => {
- expect(schemaAfterConnectionSwitch("postgres", ["public", "archive"], "archive")).toBe("archive");
- expect(schemaAfterConnectionSwitch("oracle", ["CONNECTED_USER", "APP"], "APP")).toBe("APP");
+ it.each(["postgres", "oracle", "oceanbase-oracle"] as const)("prefers a configured default schema for %s", (databaseType) => {
+ expect(schemaAfterConnectionSwitch(databaseType, ["CURRENT_OWNER", "APP"], " APP ")).toBe("APP");
});
});
diff --git a/apps/desktop/src/lib/schema/connectionSchemaInitialization.ts b/apps/desktop/src/lib/schema/connectionSchemaInitialization.ts
index 1731f053bc..929854982b 100644
--- a/apps/desktop/src/lib/schema/connectionSchemaInitialization.ts
+++ b/apps/desktop/src/lib/schema/connectionSchemaInitialization.ts
@@ -2,6 +2,6 @@ import type { DatabaseType } from "@/types/database";
export function schemaAfterConnectionSwitch(databaseType: DatabaseType | undefined, orderedSchemaNames: string[], configuredDefaultSchema?: string): string | undefined {
if (configuredDefaultSchema?.trim()) return configuredDefaultSchema.trim();
- if (databaseType !== "oracle") return undefined;
+ if (databaseType !== "oracle" && databaseType !== "oceanbase-oracle") return undefined;
return orderedSchemaNames[0];
}