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): unify server version prefix in hover details

Acd-kk5f93a772d2f5
diff --git a/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.ts b/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.ts
index c502f75249..98068e3c47 100644
--- a/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.ts
+++ b/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.ts
@@ -129,7 +129,7 @@ async function openConnectionTooltip() {
trigger.dispatchEvent(new MouseEvent("mouseenter"));
await vi.runAllTimersAsync();
await nextTick();
- return { host, node };
+ return { host, node, container };
}
afterEach(() => {
@@ -141,6 +141,38 @@ afterEach(() => {
});
describe("TreeItem visible filter connection detail", () => {
+ it.each([
+ ["mysql", "8.0", "v8.0"],
+ ["redis", "7.1.1", "v7.1.1"],
+ ["qdrant", " v1.12.0 ", "v1.12.0"],
+ ["mysql", "V8.0.36", "v8.0.36"],
+ ["mysql", "8.0.36-commercial", "v8.0.36-commercial"],
+ ["postgres", "PostgreSQL 16.4 on x86_64-pc-linux-gnu", "PostgreSQL 16.4 on x86_64-pc-linux-gnu"],
+ ["kingbase", "V009R001", "V009R001"],
+ ] as const)("shows the existing %s server version %s only in the hover details", async (db_type, productVersion, expected) => {
+ state.config = { ...mysqlConnection(), db_type, note: "Reporting connection", database_info: { productVersion } };
+
+ const { container } = await openConnectionTooltip();
+
+ const tooltip = document.querySelector('[role="tooltip"]');
+ expect(tooltip?.textContent).toContain("Server version");
+ expect(tooltip?.querySelector(`[title="${expected}"]`)?.textContent).toBe(expected);
+ expect(tooltip?.textContent).toContain("Reporting connection");
+ expect(container.textContent).not.toContain(expected);
+ expect(state.config.database_info?.productVersion).toBe(productVersion);
+ });
+
+ it.each([undefined, "", " "])("hides missing server versions without falling back to the driver version (%s)", async (productVersion) => {
+ state.config = { ...mysqlConnection(), database_info: { productVersion, driverVersion: "42.7.4" } };
+
+ await openConnectionTooltip();
+
+ const tooltip = document.querySelector('[role="tooltip"]');
+ expect(tooltip).not.toBeNull();
+ expect(tooltip?.textContent).not.toContain("Server version");
+ expect(tooltip?.textContent).not.toContain("42.7.4");
+ });
+
it("shows the tenant separator without URL escaping while copied URLs remain round-trippable", async () => {
state.config = { ...mysqlConnection(), driver_profile: "oceanbase", username: "admin@tenant", port: 2881, url_params: "password=synthetic-secret" };
diff --git a/apps/desktop/src/lib/connection/connectionDetailRows.ts b/apps/desktop/src/lib/connection/connectionDetailRows.ts
index c12c31beff..ed32ac565b 100644
--- a/apps/desktop/src/lib/connection/connectionDetailRows.ts
+++ b/apps/desktop/src/lib/connection/connectionDetailRows.ts
@@ -63,6 +63,7 @@ export function connectionDetailUrl(config: ConnectionConfig): string {
export function connectionDetailRows(config: ConnectionConfig, translate: (key: string) => string, visibleFilter?: ConnectionDetailVisibleFilter): ConnectionDetailRow[] {
const hostLabel = isLocalFileConnection(config) ? translate("connection.filePath") : translate("connection.host");
const hostValue = clean(config.host);
+ const productVersion = clean(config.database_info?.productVersion).replace(/^v?(\d+(?:\.\d+)*(?:[-+][\w.-]+)?)$/i, "v$1");
const hostValues = hostValue.includes(",")
? hostValue
.split(",")
@@ -78,7 +79,7 @@ export function connectionDetailRows(config: ConnectionConfig, translate: (key:
{ label: translate("connection.database"), value: databaseValue(config) },
{ label: translate("connection.user"), value: clean(config.username) },
{ label: translate("connection.type"), value: config.driver_label || config.driver_profile || config.db_type },
- { label: translate("connection.databaseInfo.productVersion"), value: clean(config.database_info?.productVersion) },
+ { label: translate("connection.databaseInfo.productVersion"), value: productVersion },
...(visibleFilter ? [visibleFilter] : []),
{ label: translate("connection.note"), value: clean(config.note), multiline: true },
].filter((row) => row.value);