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(kingbase): support Kingbase8 connection URLs

zipgda7386760434
diff --git a/apps/desktop/src/lib/connection/connectionPresentation.ts b/apps/desktop/src/lib/connection/connectionPresentation.ts
index 31a5a7211d..80d9109daf 100644
--- a/apps/desktop/src/lib/connection/connectionPresentation.ts
+++ b/apps/desktop/src/lib/connection/connectionPresentation.ts
@@ -144,6 +144,9 @@ export function connectionUrlPlaceholder(dbType: DatabaseType): string {
case "dameng":
return "dm://user:password@host:port";
+ case "kingbase":
+ return "kingbase8://user:password@host:54321/database";
+
case "tdengine":
return "tdengine://user:password@host:6041/database";
diff --git a/apps/desktop/src/lib/connection/connectionUrl.ts b/apps/desktop/src/lib/connection/connectionUrl.ts
index c9af4b4728..7991e44f83 100644
--- a/apps/desktop/src/lib/connection/connectionUrl.ts
+++ b/apps/desktop/src/lib/connection/connectionUrl.ts
@@ -49,6 +49,8 @@ const SCHEME_PROFILES: Record<string, ConnectionProfile> = {
chromadb: { type: "chromadb", profile: "chromadb", label: "ChromaDB", defaultPort: 8000 },
dm: { type: "dameng", profile: "dm", label: "DM (Dameng)", defaultPort: 5236 },
dameng: { type: "dameng", profile: "dm", label: "DM (Dameng)", defaultPort: 5236 },
+ kingbase: { type: "kingbase", profile: "kingbase", label: "KingBase", defaultPort: 54321 },
+ kingbase8: { type: "kingbase", profile: "kingbase", label: "KingBase", defaultPort: 54321 },
gaussdb: { type: "gaussdb", profile: "gaussdb", label: "GaussDB", defaultPort: 5432 },
kwdb: { type: "kwdb", profile: "kwdb", label: "KWDB", defaultPort: 26257 },
gbase: { type: "gbase", profile: "gbase", label: "GBase", defaultPort: 5258 },
@@ -591,6 +593,9 @@ function applyParsedUsername(config: Omit<ConnectionConfig, "id">, parsed: Parse
if (parsed.dbType === "h2" && config.db_type === "h2" && !h2JdbcUrlHasUserParam(parsed.connectionString)) {
return config.username || parsed.username;
}
+ if (parsed.dbType === "kingbase" && config.db_type === "kingbase" && !parsed.username) {
+ return config.username;
+ }
return parsed.username;
}
@@ -598,6 +603,9 @@ function applyParsedPassword(config: Omit<ConnectionConfig, "id">, parsed: Parse
if (parsed.dbType === "h2" && config.db_type === "h2" && !h2JdbcUrlHasPasswordParam(parsed.connectionString)) {
return config.password || parsed.password;
}
+ if (parsed.dbType === "kingbase" && config.db_type === "kingbase" && !parsed.password) {
+ return config.password;
+ }
return parsed.password;
}
diff --git a/packages/app-tests/connectionUrl.test.ts b/packages/app-tests/connectionUrl.test.ts
index 339107b58a..0a071d6d5a 100644
--- a/packages/app-tests/connectionUrl.test.ts
+++ b/packages/app-tests/connectionUrl.test.ts
@@ -1,6 +1,7 @@
import { strict as assert } from "node:assert";
import { test } from "vitest";
import { applyParsedConnectionUrl, normalizeMongoConnectionString, parseConnectionUrl } from "../../apps/desktop/src/lib/connection/connectionUrl.ts";
+import { connectionUrlPlaceholder } from "../../apps/desktop/src/lib/connection/connectionPresentation.ts";
import { h2FileJdbcUrlWithPath } from "../../apps/desktop/src/lib/database/h2Connection.ts";
test("parses postgres connection URLs", () => {
@@ -33,6 +34,36 @@ test("parses KWDB connection URLs", () => {
});
});
+test.each(["kingbase", "kingbase8", "jdbc:kingbase8"])("parses %s connection URLs as native KingBase connections", (scheme) => {
+ assert.deepEqual(parseConnectionUrl(`${scheme}://framework:[email protected]:443/hq_official?sslmode=disable`), {
+ dbType: "kingbase",
+ driverProfile: "kingbase",
+ driverLabel: "KingBase",
+ host: "172.21.203.70",
+ port: 443,
+ username: "framework",
+ password: "secret",
+ database: "hq_official",
+ urlParams: "sslmode=disable",
+ ssl: false,
+ });
+});
+
+test("shows the vendor KingBase URL scheme in the connection form", () => {
+ assert.equal(connectionUrlPlaceholder("kingbase"), "kingbase8://user:password@host:54321/database");
+});
+
+test("applies a credential-free KingBase URL without clearing typed credentials", () => {
+ const parsed = parseConnectionUrl("kingbase8://172.21.203.70:443/hq_official");
+ const applied = applyParsedConnectionUrl({ name: "hq", db_type: "kingbase", username: "framework", password: "typed-secret" } as any, parsed);
+
+ assert.equal(applied.host, "172.21.203.70");
+ assert.equal(applied.port, 443);
+ assert.equal(applied.database, "hq_official");
+ assert.equal(applied.username, "framework");
+ assert.equal(applied.password, "typed-secret");
+});
+
test("parses mysql URLs with encoded credentials", () => {
const parsed = parseConnectionUrl("mysql://root:p%[email protected]/shop?charset=utf8mb4");