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(gbase): sync type label after version switch

zipg3858cf1e5983
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue
index 63736f324f..adaec26922 100644
--- a/apps/desktop/src/components/connection/ConnectionDialog.vue
+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue
@@ -1331,7 +1331,8 @@ function profileForConfig(config: ConnectionConfig) {
}
function selectedProfile() {
- return driverProfiles[selectedType.value] ?? driverProfiles.mysql;
+ const profile = selectedType.value === "gbase" && (form.value.driver_profile === "gbase8a" || form.value.driver_profile === "gbase8s") ? form.value.driver_profile : selectedType.value;
+ return driverProfiles[profile] ?? driverProfiles.mysql;
}
function mqExtraRecord(config?: Partial<MqAdminConfig>): Record<string, unknown> {
diff --git a/apps/desktop/src/lib/__tests__/connection/gbase8sConnectionDialog.spec.ts b/apps/desktop/src/lib/__tests__/connection/gbase8sConnectionDialog.spec.ts
index 6e13849d7d..8ebec16ad0 100644
--- a/apps/desktop/src/lib/__tests__/connection/gbase8sConnectionDialog.spec.ts
+++ b/apps/desktop/src/lib/__tests__/connection/gbase8sConnectionDialog.spec.ts
@@ -1,10 +1,47 @@
import { readFileSync } from "node:fs";
+import { parse } from "vue/compiler-sfc";
+import ts from "typescript";
import { describe, expect, it } from "vitest";
const dialogSource = readFileSync(new URL("../../../components/connection/ConnectionDialog.vue", import.meta.url), "utf8");
+const parsedDialog = parse(dialogSource, { filename: "ConnectionDialog.vue" });
+
+function selectedProfileHarness(selectedTypeValue: string, driverProfile: string) {
+ const script = parsedDialog.descriptor.scriptSetup;
+ expect(parsedDialog.errors).toEqual([]);
+ expect(script).toBeDefined();
+ const source = ts.createSourceFile("ConnectionDialog.vue.ts", script!.content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
+ const declaration = source.statements.find((statement): statement is ts.FunctionDeclaration => ts.isFunctionDeclaration(statement) && statement.name?.text === "selectedProfile");
+ expect(declaration).toBeDefined();
+ const javascript = ts.transpileModule(declaration!.getText(), {
+ compilerOptions: { module: ts.ModuleKind.None, target: ts.ScriptTarget.ES2022 },
+ }).outputText;
+ const selectedProfile = new Function("driverProfiles", "selectedType", "form", `${javascript}\nreturn selectedProfile;`)(
+ {
+ mysql: { label: "MySQL" },
+ gbase: { label: "南大通用 GBase 8a" },
+ gbase8a: { label: "南大通用 GBase 8a" },
+ gbase8s: { label: "南大通用 GBase 8s" },
+ },
+ { value: selectedTypeValue },
+ { value: { driver_profile: driverProfile } },
+ ) as () => { label: string };
+ return selectedProfile();
+}
describe("GBase 8s connection dialog", () => {
it("hydrates DBSERVERNAME when editing a saved connection", () => {
expect(dialogSource).toContain('gbase_server: config.gbase_server || ""');
});
+
+ it.each([
+ ["gbase8a", "南大通用 GBase 8a"],
+ ["gbase8s", "南大通用 GBase 8s"],
+ ])("shows the active %s profile in the merged GBase type field", (profile, label) => {
+ expect(selectedProfileHarness("gbase", profile).label).toBe(label);
+ });
+
+ it("keeps non-GBase type labels based on the selected picker type", () => {
+ expect(selectedProfileHarness("mysql", "gbase8s").label).toBe("MySQL");
+ });
});