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(connection): preserve custom OceanBase port across mode switch

efeirebd98b72bed43
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue
index f6e1aa63fc..0f185beacc 100644
--- a/apps/desktop/src/components/connection/ConnectionDialog.vue
+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue
@@ -3128,6 +3128,9 @@ function applyRequestedPluginProvider(target: PluginCenterFocus | null | undefin
}
function switchOceanbaseMode(mode: "mysql" | "oracle") {
+ const port = form.value.port;
+ const sourceProfile = oceanbaseSubMode.value === "mysql" ? "oceanbase" : "oceanbase-oracle";
+ const preservePort = port !== driverProfiles[sourceProfile].port;
oceanbaseSubMode.value = mode;
if (mode === "mysql") {
applyProfile("oceanbase", false);
@@ -3135,6 +3138,7 @@ function switchOceanbaseMode(mode: "mysql" | "oracle") {
applyProfile("oceanbase-oracle", false);
selectedType.value = "oceanbase";
}
+ if (preservePort) form.value.port = port;
resetTestState();
}
diff --git a/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts b/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts
index 78a7053b20..f2d9d0d38e 100644
--- a/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts
+++ b/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts
@@ -5,6 +5,7 @@ import { createPinia, setActivePinia } from "pinia";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import i18n from "@/i18n";
import type { ConnectionConfig } from "@/types/database";
+import { CONNECTION_PROFILES } from "@/types/generated/connectionProfiles";
import { parseConnectionDeepLink, parseConnectionDeepLinkUpdate } from "@/lib/connection/connectionDeepLink";
const visibleTab = vi.hoisted(() => ({ value: "connection" }));
@@ -251,6 +252,102 @@ afterEach(() => {
});
describe("ConnectionDialog deep-link edit confirmation", () => {
+ it("saves a new OceanBase connection with its explicitly entered port after switching mode", async () => {
+ backend.listInstalledAgentsLocal.mockResolvedValue([{ db_type: "oceanbase-oracle", installed: true }]);
+ await mountNewDialog();
+ const category = [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === i18n.global.t("connection.databaseCategoryDomestic"));
+ expect(category).toBeTruthy();
+ category!.click();
+ await settle();
+ const option = document.querySelector<HTMLButtonElement>('[title="OceanBase"]');
+ expect(option).toBeTruthy();
+ option!.click();
+ await settle();
+ option!.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
+ await settle();
+ const port = document.querySelector<HTMLInputElement>('input[type="number"].col-span-1');
+ expect(port?.value).toBe("2883");
+ port!.value = "2881";
+ port!.dispatchEvent(new Event("input", { bubbles: true }));
+ await settle();
+ const mode = [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === i18n.global.t("connection.oceanbaseOracleMode"));
+ mode!.click();
+ await settle();
+ const save = [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === i18n.global.t("connection.saveAndConnect"));
+ expect(save).toBeTruthy();
+ save!.click();
+ await settle();
+ expect(store.addConnection).toHaveBeenCalledWith(expect.objectContaining({ db_type: "oceanbase-oracle", driver_profile: "oceanbase-oracle", port: 2881 }), null);
+ });
+
+ it.each([false, true])("follows each OceanBase profile default in both directions (Oracle source: %s)", async (oracle) => {
+ const mysqlPort = CONNECTION_PROFILES.oceanbase.port;
+ const oraclePort = CONNECTION_PROFILES["oceanbase-oracle"].port;
+ try {
+ Object.defineProperty(CONNECTION_PROFILES.oceanbase, "port", { value: 12881, configurable: true });
+ Object.defineProperty(CONNECTION_PROFILES["oceanbase-oracle"], "port", { value: 12883, configurable: true });
+ await mountDialog(savedConnection({ db_type: oracle ? "oceanbase-oracle" : "mysql", driver_profile: oracle ? "oceanbase-oracle" : "oceanbase", port: oracle ? 12883 : 12881 }), "");
+ for (const targetOracle of [!oracle, oracle]) {
+ const portInput = document.querySelector<HTMLInputElement>('input[type="number"].col-span-1')!;
+ for (const value of ["12889", String(targetOracle ? 12881 : 12883)]) {
+ portInput.value = value;
+ portInput.dispatchEvent(new Event("input", { bubbles: true }));
+ await settle();
+ }
+ const key = targetOracle ? "connection.oceanbaseOracleMode" : "connection.oceanbaseMySQLMode";
+ const mode = [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === i18n.global.t(key));
+ mode!.click();
+ await settle();
+ expect(document.querySelector<HTMLInputElement>('input[type="number"].col-span-1')?.value).toBe(String(targetOracle ? 12883 : 12881));
+ }
+ const customPort = document.querySelector<HTMLInputElement>('input[type="number"].col-span-1')!;
+ customPort.value = "12889";
+ customPort.dispatchEvent(new Event("input", { bubbles: true }));
+ await settle();
+ for (const targetOracle of [!oracle, oracle]) {
+ const key = targetOracle ? "connection.oceanbaseOracleMode" : "connection.oceanbaseMySQLMode";
+ [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === i18n.global.t(key))!.click();
+ await settle();
+ expect(document.querySelector<HTMLInputElement>('input[type="number"].col-span-1')?.value).toBe("12889");
+ }
+ } finally {
+ Object.defineProperty(CONNECTION_PROFILES.oceanbase, "port", { value: mysqlPort, configurable: true });
+ Object.defineProperty(CONNECTION_PROFILES["oceanbase-oracle"], "port", { value: oraclePort, configurable: true });
+ }
+ });
+
+ it.each([
+ { port: 2881, oracle: false },
+ { port: 12883, oracle: false },
+ { port: 2883, oracle: false },
+ { port: 2881, oracle: true },
+ { port: 12883, oracle: true },
+ ])("retains OceanBase port $port (Oracle source: $oracle) across compatibility mode switches and save", async ({ port, oracle }) => {
+ backend.listInstalledAgentsLocal.mockResolvedValue([{ db_type: "oceanbase-oracle", installed: true }]);
+ await mountDialog(savedConnection({ db_type: oracle ? "oceanbase-oracle" : "mysql", driver_profile: oracle ? "oceanbase-oracle" : "oceanbase", driver_label: "OceanBase", port: 2883 }), "");
+ const portInput = document.querySelector<HTMLInputElement>('input[type="number"].col-span-1');
+ expect(portInput).toBeTruthy();
+ portInput!.value = String(port);
+ portInput!.dispatchEvent(new Event("input", { bubbles: true }));
+ await settle();
+ const clickMode = async (key: "connection.oceanbaseOracleMode" | "connection.oceanbaseMySQLMode") => {
+ const button = [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === i18n.global.t(key));
+ expect(button).toBeTruthy();
+ button!.click();
+ await settle();
+ const portInput = document.querySelector<HTMLInputElement>('input[type="number"].col-span-1');
+ expect(portInput?.value).toBe(String(port));
+ };
+ await clickMode("connection.oceanbaseOracleMode");
+ await clickMode("connection.oceanbaseOracleMode");
+ await clickMode("connection.oceanbaseMySQLMode");
+ await clickMode("connection.oceanbaseOracleMode");
+ const save = [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === "Save");
+ save!.click();
+ await settle();
+ expect(store.updateConnection).toHaveBeenCalledWith(expect.objectContaining({ db_type: "oceanbase-oracle", driver_profile: "oceanbase-oracle", port, username: "SYS", url_params: "", host: "old.example.test", password: "old-password" }));
+ });
+
it("preserves a protected generic JDBC target when only its name changes", async () => {
const saved = savedConnection({
db_type: "jdbc",