From 651f838a7d92af711875e357bbae6dd94910be39 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Wed, 3 Jun 2026 18:07:14 +0800 Subject: [PATCH] feat(gbase): add GBase 8s driver profile --- .../connection/ConnectionDialog.vue | 35 ++++++++++++++++++- .../src/components/icons/DatabaseIcon.vue | 1 + .../desktop/src/lib/agentDriverInstallHint.ts | 2 +- apps/desktop/src/lib/connectionUrl.ts | 29 +++++++++++++++ apps/desktop/src/lib/visibleDatabases.ts | 5 ++- .../assets/database-drivers.manifest.json | 5 ++- crates/dbx-core/src/agent_catalog.rs | 5 ++- crates/dbx-core/src/agent_manager.rs | 3 ++ .../app-tests/agentDriverInstallHint.test.ts | 25 +++++++++++++ packages/app-tests/connectionUrl.test.ts | 16 +++++++++ packages/app-tests/visibleDatabases.test.ts | 9 +++++ 11 files changed, 130 insertions(+), 5 deletions(-) diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue index c35023eed5..12a1e1ac6e 100644 --- a/apps/desktop/src/components/connection/ConnectionDialog.vue +++ b/apps/desktop/src/components/connection/ConnectionDialog.vue @@ -271,6 +271,7 @@ const driverProfiles: Record< firebird: { type: "firebird", port: 3050, user: "SYSDBA", label: "Firebird", icon: "firebird" }, exasol: { type: "exasol", port: 8563, user: "sys", label: "Exasol", icon: "exasol" }, gbase: { type: "gbase", port: 5258, user: "gbasedbt", label: "GBase", icon: "gbase" }, + gbase8s: { type: "gbase", port: 9088, user: "gbasedbt", label: "GBase 8s", icon: "gbase" }, opengauss: { type: "opengauss", port: 5432, @@ -409,6 +410,12 @@ function switchOceanbaseMode(mode: "mysql" | "oracle") { resetTestState(); } +function switchGbaseProfile(profile: "gbase" | "gbase8s") { + applyProfile(profile, false); + selectedType.value = "gbase"; + resetTestState(); +} + watch( () => props.editConfig, (config) => { @@ -466,6 +473,9 @@ watch( if (profile === "oceanbase") { oceanbaseSubMode.value = config.driver_profile === "oceanbase-oracle" ? "oracle" : "mysql"; } + if (profile === "gbase8s") { + selectedType.value = "gbase"; + } mongoUseUrl.value = !!config.connection_string; jdbcDriverPathsInput.value = (config.jdbc_driver_paths || []).join("\n"); customDriverName.value = isCustomCompatibleProfile() ? config.driver_label || "" : ""; @@ -771,7 +781,7 @@ const canUseProxy = computed( () => form.value.db_type !== "sqlite" && form.value.db_type !== "duckdb" && form.value.db_type !== "access", ); const shouldShowAgentDriverInstallHint = computed(() => - showAgentDriverInstallHint(form.value.db_type, agentDrivers.value, selectedType.value), + showAgentDriverInstallHint(form.value.db_type, agentDrivers.value, form.value.driver_profile), ); const testResultMessage = computed(() => { if (!testResult.value) return ""; @@ -1225,6 +1235,9 @@ function applyConnectionPrefill(draft: ConnectionDeepLinkDraft) { oceanbaseSubMode.value = "oracle"; selectedType.value = "oceanbase"; } + if (draft.driverProfile === "gbase8s") { + selectedType.value = "gbase"; + } customDriverName.value = isCustomCompatibleProfile() ? draft.driverLabel : ""; mongoUseUrl.value = !!draft.useMongoUrl; if (draft.name?.trim()) { @@ -1814,6 +1827,26 @@ function openExternalUrl(url: string) { +
+ +
+ + +
+
+
= { firebird: "firebird.webp", exasol: "exasol.webp", gbase: "gbase.webp", + gbase8s: "gbase.webp", tdsql: "tdsql.webp", polardb: "polardb.webp", greatsql: "greatsql.webp", diff --git a/apps/desktop/src/lib/agentDriverInstallHint.ts b/apps/desktop/src/lib/agentDriverInstallHint.ts index 68ae9d38dc..981ec73625 100644 --- a/apps/desktop/src/lib/agentDriverInstallHint.ts +++ b/apps/desktop/src/lib/agentDriverInstallHint.ts @@ -12,6 +12,6 @@ export function showAgentDriverInstallHint( driverProfile?: string, ): boolean { if (!supportsDriverManagement(dbType)) return false; - const driverKey = dbType === "oracle" && driverProfile ? driverProfile : dbType; + const driverKey = driverProfile && driverProfile !== dbType ? driverProfile : dbType; return drivers.find((driver) => driver.db_type === driverKey)?.installed !== true; } diff --git a/apps/desktop/src/lib/connectionUrl.ts b/apps/desktop/src/lib/connectionUrl.ts index a94b4e5fc7..26504da5f3 100644 --- a/apps/desktop/src/lib/connectionUrl.ts +++ b/apps/desktop/src/lib/connectionUrl.ts @@ -41,6 +41,8 @@ const SCHEME_PROFILES: Record = { dm: { type: "dameng", profile: "dm", label: "DM (Dameng)", defaultPort: 5236 }, dameng: { type: "dameng", profile: "dm", label: "DM (Dameng)", defaultPort: 5236 }, gaussdb: { type: "gaussdb", profile: "gaussdb", label: "GaussDB", defaultPort: 5432 }, + gbase: { type: "gbase", profile: "gbase", label: "GBase", defaultPort: 5258 }, + "gbasedbt-sqli": { type: "gbase", profile: "gbase8s", label: "GBase 8s", defaultPort: 9088 }, yashandb: { type: "yashandb", profile: "yashandb", label: "YashanDB", defaultPort: 1688 }, opengauss: { type: "gaussdb", profile: "opengauss", label: "openGauss", defaultPort: 5432 }, tdengine: { type: "tdengine", profile: "tdengine", label: "TDengine", defaultPort: 6041 }, @@ -284,6 +286,31 @@ function parseJdbcUCanAccessUrl(source: string): ParsedConnectionUrl | null { }; } +function parseJdbcGbase8sUrl(source: string): ParsedConnectionUrl | null { + const match = + /^jdbc:gbasedbt-sqli:\/\/(?:(?[^@/?#]*)@)?(?\[[^\]]+\]|[^:/?#]+)(?::(?\d+))?\/(?[^:?#]*)(?::(?[^?#]*))?/i.exec( + source, + ); + if (!match?.groups) return null; + + const rawUserInfo = match.groups.userinfo || ""; + const [rawUser = "", ...passwordParts] = rawUserInfo.split(":"); + const host = match.groups.host.replace(/^\[/, "").replace(/\]$/, ""); + + return { + dbType: "gbase", + driverProfile: "gbase8s", + driverLabel: "GBase 8s", + host, + port: match.groups.port ? Number(match.groups.port) : 9088, + username: decodeUrlPart(rawUser), + password: decodeUrlPart(passwordParts.join(":")), + database: decodeUrlPart(match.groups.database || ""), + urlParams: match.groups.params || "", + ssl: false, + }; +} + export function parseConnectionUrl(value: string, preferredProfile?: string): ParsedConnectionUrl { const input = value.trim(); if (!input) { @@ -291,6 +318,8 @@ export function parseConnectionUrl(value: string, preferredProfile?: string): Pa } const jdbcUCanAccess = parseJdbcUCanAccessUrl(input); if (jdbcUCanAccess) return jdbcUCanAccess; + const jdbcGbase8s = parseJdbcGbase8sUrl(input); + if (jdbcGbase8s) return jdbcGbase8s; const jdbcOracle = parseJdbcOracleUrl(input); if (jdbcOracle) return jdbcOracle; const jdbcSqlServer = parseJdbcSqlServerUrl(input); diff --git a/apps/desktop/src/lib/visibleDatabases.ts b/apps/desktop/src/lib/visibleDatabases.ts index 8637182a9c..914c25eef0 100644 --- a/apps/desktop/src/lib/visibleDatabases.ts +++ b/apps/desktop/src/lib/visibleDatabases.ts @@ -90,11 +90,14 @@ export function isSystemDatabaseName(databaseType: DatabaseType | undefined, dat export function filterDatabaseNamesForConnection( databaseNames: string[], - connection: Pick | undefined, + connection: Pick | undefined, ): string[] { const visibleDatabases = connection?.visible_databases; if (visibleDatabaseFilterIsEnabled(visibleDatabases)) { return filterVisibleDatabaseNames(databaseNames, visibleDatabases); } + if (connection?.db_type === "gbase" && connection.driver_profile === "gbase8s") { + return databaseNames; + } return databaseNames.filter((name) => !isSystemDatabaseName(connection?.db_type, name)); } diff --git a/crates/dbx-core/assets/database-drivers.manifest.json b/crates/dbx-core/assets/database-drivers.manifest.json index 4dcaa5c3e8..592b7725e7 100644 --- a/crates/dbx-core/assets/database-drivers.manifest.json +++ b/crates/dbx-core/assets/database-drivers.manifest.json @@ -307,7 +307,10 @@ "singleConnectionPool": false, "metadataConnectionScoped": false, "skipTcpProbe": true, - "defaultPort": 5258 + "defaultPort": 5258, + "driverProfiles": [ + { "profile": "gbase8s", "label": "GBase 8s", "agentKey": "gbase8s" } + ] }, { "dbType": "access", diff --git a/crates/dbx-core/src/agent_catalog.rs b/crates/dbx-core/src/agent_catalog.rs index c663777fc3..1eac13bc8c 100644 --- a/crates/dbx-core/src/agent_catalog.rs +++ b/crates/dbx-core/src/agent_catalog.rs @@ -22,6 +22,9 @@ const ORACLE_PROFILES: &[AgentDriverProfile] = &[ AgentDriverProfile { profile: "oracle-10g", key: "oracle-10g", label: "Oracle 10g", store_visible: true }, ]; +const GBASE_PROFILES: &[AgentDriverProfile] = + &[AgentDriverProfile { profile: "gbase8s", key: "gbase8s", label: "GBase 8s", store_visible: true }]; + const AGENT_CATALOG: &[AgentCatalogEntry] = &[ AgentCatalogEntry { db_type: DatabaseType::Dameng, @@ -112,7 +115,7 @@ const AGENT_CATALOG: &[AgentCatalogEntry] = &[ key: "gbase", label: "GBase", store_visible: true, - profiles: &[], + profiles: GBASE_PROFILES, }, AgentCatalogEntry { db_type: DatabaseType::Access, diff --git a/crates/dbx-core/src/agent_manager.rs b/crates/dbx-core/src/agent_manager.rs index afb667cda2..438c800e29 100644 --- a/crates/dbx-core/src/agent_manager.rs +++ b/crates/dbx-core/src/agent_manager.rs @@ -159,8 +159,11 @@ mod tests { Some("oracle-legacy") ); assert_eq!(AgentManager::db_type_to_agent_key(&DatabaseType::Oracle, None), Some("oracle")); + assert_eq!(AgentManager::db_type_to_agent_key(&DatabaseType::Gbase, Some("gbase8s")), Some("gbase8s")); + assert_eq!(AgentManager::db_type_to_agent_key(&DatabaseType::Gbase, None), Some("gbase")); manager.stop_daemon_by_key("oracle-legacy").await; manager.stop_daemon_by_key("oracle-10g").await; + manager.stop_daemon_by_key("gbase8s").await; } } diff --git a/packages/app-tests/agentDriverInstallHint.test.ts b/packages/app-tests/agentDriverInstallHint.test.ts index 00ccc88572..fae78f067c 100644 --- a/packages/app-tests/agentDriverInstallHint.test.ts +++ b/packages/app-tests/agentDriverInstallHint.test.ts @@ -61,3 +61,28 @@ test("uses the selected Oracle driver profile for install hints", () => { ); assert.equal(showAgentDriverInstallHint("oracle", [{ db_type: "oracle", installed: false }], "oracle"), true); }); + +test("uses selected non-Oracle agent driver profiles for install hints", () => { + assert.equal( + showAgentDriverInstallHint( + "gbase", + [ + { db_type: "gbase", installed: true }, + { db_type: "gbase8s", installed: false }, + ], + "gbase8s", + ), + true, + ); + assert.equal( + showAgentDriverInstallHint( + "gbase", + [ + { db_type: "gbase", installed: false }, + { db_type: "gbase8s", installed: true }, + ], + "gbase8s", + ), + false, + ); +}); diff --git a/packages/app-tests/connectionUrl.test.ts b/packages/app-tests/connectionUrl.test.ts index 5103b94abb..7ac9d7d6d4 100644 --- a/packages/app-tests/connectionUrl.test.ts +++ b/packages/app-tests/connectionUrl.test.ts @@ -120,6 +120,22 @@ test("parses XuguDB JDBC URLs", () => { assert.equal(parsed.urlParams, "charset=utf8"); }); +test("parses GBase 8s JDBC URLs", () => { + const parsed = parseConnectionUrl( + "jdbc:gbasedbt-sqli://gbasedbt:secret@gbase.example.com:20013/testdb:GBASEDBTSERVER=gbase01;CLIENT_LOCALE=zh_cn.utf8", + ); + + assert.equal(parsed.dbType, "gbase"); + assert.equal(parsed.driverProfile, "gbase8s"); + assert.equal(parsed.driverLabel, "GBase 8s"); + assert.equal(parsed.host, "gbase.example.com"); + assert.equal(parsed.port, 20013); + assert.equal(parsed.username, "gbasedbt"); + assert.equal(parsed.password, "secret"); + assert.equal(parsed.database, "testdb"); + assert.equal(parsed.urlParams, "GBASEDBTSERVER=gbase01;CLIENT_LOCALE=zh_cn.utf8"); +}); + test("parses UCanAccess JDBC URLs as Access database files", () => { const parsed = parseConnectionUrl("jdbc:ucanaccess:///Users/me/data/Northwind.accdb;memory=false"); diff --git a/packages/app-tests/visibleDatabases.test.ts b/packages/app-tests/visibleDatabases.test.ts index 7cddddadec..d97d9223a6 100644 --- a/packages/app-tests/visibleDatabases.test.ts +++ b/packages/app-tests/visibleDatabases.test.ts @@ -41,6 +41,15 @@ test("mysql system databases are hidden by default but can be explicitly selecte assert.equal(isSystemDatabaseName("postgres", "information_schema"), false); }); +test("gbase8s does not inherit base gbase system database filtering", () => { + const databases = ["app", "information_schema", "mysql", "performance_schema", "sys"]; + assert.deepEqual(filterDatabaseNamesForConnection(databases, { db_type: "gbase" }), ["app"]); + assert.deepEqual( + filterDatabaseNamesForConnection(databases, { db_type: "gbase", driver_profile: "gbase8s" }), + databases, + ); +}); + test("system database detection is registered per database type", () => { assert.deepEqual(filterDatabaseNamesForConnection(["default", "system"], { db_type: "clickhouse" }), ["default"]); assert.deepEqual(filterDatabaseNamesForConnection(["master", "app", "tempdb"], { db_type: "sqlserver" }), ["app"]);