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(oceanbase): preserve oracle mode when editing connection
t8y26646b432d3a1
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vueindex 6201cfb0f9..9f8dbff2ef 100644--- a/apps/desktop/src/components/connection/ConnectionDialog.vue+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue@@ -40,6 +40,7 @@ import { buildDraftVisibleDatabasesConnectionId, connectionCanChooseVisibleDatabimport { canSaveVisibleDatabaseSelection, filterDatabaseNamesForConnection, isSystemDatabaseName, normalizeVisibleDatabaseSelection, buildDraftVisibleSchemasConnectionId, normalizeVisibleSchemaSelection } from "@/lib/visibleDatabases";import { isSchemaAware } from "@/lib/databaseFeatureSupport";import VisibleSchemasDialog from "@/components/sidebar/VisibleSchemasDialog.vue";+import { oceanbaseModeConnectionPatch, oceanbaseSubModeFromConfig } from "@/lib/oceanbaseConnectionMode";type DbOption = { value: string; label: string };type DbCategory = { key: string; title: string; options: DbOption[] };@@ -885,13 +886,15 @@ watch(if (config) {const legacyConfig = config as LegacyConnectionConfig;const profile = profileForConfig(config);+ const oceanbaseMode = profile === "oceanbase" ? oceanbaseSubModeFromConfig(config) : "mysql";+ const oceanbasePatch = profile === "oceanbase" ? oceanbaseModeConnectionPatch(oceanbaseMode) : null;editingId.value = config.id;const profileConfig = driverProfiles[profile];form.value = {name: config.name,- db_type: profileConfig?.type || config.db_type,- driver_profile: profile,- driver_label: config.driver_label || driverProfiles[profile]?.label || config.db_type,+ db_type: oceanbasePatch?.db_type || profileConfig?.type || config.db_type,+ driver_profile: oceanbasePatch?.driver_profile || profile,+ driver_label: config.driver_label || oceanbasePatch?.driver_label || driverProfiles[profile]?.label || config.db_type,url_params: config.url_params || "",host: config.db_type === "h2" ? config.host || h2FilePathFromJdbcUrl(config.connection_string) : config.host,port: profile === "tdengine" && (config.port === 0 || config.port === 6030) ? 6041 : config.port,@@ -941,7 +944,7 @@ watch(selectedTransportLayerId.value = form.value.transport_layers?.[0]?.id || null;selectedType.value = profile;if (profile === "oceanbase") {- oceanbaseSubMode.value = config.driver_profile === "oceanbase-oracle" ? "oracle" : "mysql";+ oceanbaseSubMode.value = oceanbaseMode;}if (profile === "gbase8a" || profile === "gbase8s") {selectedType.value = "gbase";@@ -1489,6 +1492,9 @@ function generateConnectionName(): string {function connectionConfigForSubmit(id: string): ConnectionConfig {const config = { ...form.value, id } as LegacyConnectionConfig;+ if (selectedType.value === "oceanbase") {+ Object.assign(config, oceanbaseModeConnectionPatch(oceanbaseSubMode.value));+ }if (!config.name?.trim()) {config.name = generateConnectionName();}diff --git a/apps/desktop/src/lib/oceanbaseConnectionMode.ts b/apps/desktop/src/lib/oceanbaseConnectionMode.tsnew file mode 100644index 0000000000..4b59665ed0--- /dev/null+++ b/apps/desktop/src/lib/oceanbaseConnectionMode.ts@@ -0,0 +1,26 @@+import type { ConnectionConfig, DatabaseType } from "@/types/database";++export type OceanbaseSubMode = "mysql" | "oracle";++export function oceanbaseSubModeFromConfig(config: Pick<ConnectionConfig, "db_type" | "driver_profile">): OceanbaseSubMode {+ return config.db_type === "oceanbase-oracle" || config.driver_profile === "oceanbase-oracle" ? "oracle" : "mysql";+}++export function oceanbaseModeConnectionPatch(mode: OceanbaseSubMode): {+ db_type: DatabaseType;+ driver_profile: string;+ driver_label: string;+} {+ if (mode === "oracle") {+ return {+ db_type: "oceanbase-oracle",+ driver_profile: "oceanbase-oracle",+ driver_label: "OceanBase Oracle Mode",+ };+ }+ return {+ db_type: "mysql",+ driver_profile: "oceanbase",+ driver_label: "OceanBase",+ };+}diff --git a/packages/app-tests/oceanbaseConnectionMode.test.ts b/packages/app-tests/oceanbaseConnectionMode.test.tsnew file mode 100644index 0000000000..bc4ce1b7c3--- /dev/null+++ b/packages/app-tests/oceanbaseConnectionMode.test.ts@@ -0,0 +1,22 @@+import { strict as assert } from "node:assert";+import { test } from "vitest";+import { oceanbaseModeConnectionPatch, oceanbaseSubModeFromConfig } from "../../apps/desktop/src/lib/oceanbaseConnectionMode.ts";++test("detects OceanBase Oracle mode from either database type or driver profile", () => {+ assert.equal(oceanbaseSubModeFromConfig({ db_type: "mysql", driver_profile: "oceanbase-oracle" }), "oracle");+ assert.equal(oceanbaseSubModeFromConfig({ db_type: "oceanbase-oracle", driver_profile: "oceanbase" }), "oracle");+ assert.equal(oceanbaseSubModeFromConfig({ db_type: "mysql", driver_profile: "oceanbase" }), "mysql");+});++test("builds submit config identity from the selected OceanBase mode", () => {+ assert.deepEqual(oceanbaseModeConnectionPatch("oracle"), {+ db_type: "oceanbase-oracle",+ driver_profile: "oceanbase-oracle",+ driver_label: "OceanBase Oracle Mode",+ });+ assert.deepEqual(oceanbaseModeConnectionPatch("mysql"), {+ db_type: "mysql",+ driver_profile: "oceanbase",+ driver_label: "OceanBase",+ });+});