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(navicatImport): 修复 OceanBase NCX 连接导入模式 (#1963)

weihan31290a09c9f1
diff --git a/apps/desktop/src/lib/navicatImport.ts b/apps/desktop/src/lib/navicatImport.ts
index ca0712b912..5ebfb221ee 100644
--- a/apps/desktop/src/lib/navicatImport.ts
+++ b/apps/desktop/src/lib/navicatImport.ts
@@ -164,15 +164,18 @@ async function parseConnection(node: ParsedNode): Promise<ConnectionConfig | nul
return null;
}
- // Navicat NCX uses ServiceProvider to distinguish vendor-specific database types.
- // e.g. OceanBase Oracle reports ConnType="ORACLE" ServiceProvider="AliyunOceanBase"
+ // Navicat NCX uses ServiceProvider to distinguish vendor-specific database providers.
+ // e.g. OceanBase MySQL reports ConnType="MYSQL" ServiceProvider="AliyunOceanBase"
+ // OceanBase Oracle reports ConnType="ORACLE" ServiceProvider="AliyunOceanBase"
// GaussDB reports ConnType="POSTGRESQL" ServiceProvider="HuaweiCloudGaussDB"
+ // For OceanBase, ConnType remains the source of truth for the compatibility mode.
const serviceProvider = getAny(node.values, ["serviceprovider"]);
let effectiveProfile = profile;
if (serviceProvider) {
const sp = serviceProvider.toLowerCase();
if (sp.includes("oceanbase")) {
- effectiveProfile = { ...profile, dbType: "oceanbase-oracle", profile: "oceanbase", label: "OceanBase", port: 2881 };
+ const oceanbaseOracleMode = normalizeKey(rawType).includes("oracle") || profile.dbType === "oracle";
+ effectiveProfile = oceanbaseOracleMode ? { ...profile, dbType: "oceanbase-oracle", profile: "oceanbase-oracle", label: "OceanBase Oracle Mode", port: 2881 } : { ...profile, dbType: "mysql", profile: "oceanbase", label: "OceanBase", port: 2881 };
} else if (sp.includes("gaussdb") || sp.includes("huaweicloudgauss")) {
effectiveProfile = { ...profile, dbType: "gaussdb", profile: "gaussdb", label: "GaussDB", port: 8000 };
}
@@ -181,7 +184,8 @@ async function parseConnection(node: ParsedNode): Promise<ConnectionConfig | nul
const sqlitePath = effectiveProfile.dbType === "sqlite" ? getSqlitePath(node.values) : "";
const name = getAny(node.values, ["name", "connectionName", "connName", "caption", "title"]) || getAny(node.values, ["host", "server", "hostname"]) || sqlitePath || effectiveProfile.label;
const host = sqlitePath || getAny(node.values, ["host", "server", "hostname", "serverHost", "address"]) || (effectiveProfile.dbType === "sqlite" ? "" : "127.0.0.1");
- const database = effectiveProfile.dbType === "sqlite" ? sqlitePath : getAny(node.values, ["database", "databaseName", "initialDatabase", "serviceName", "sid", "schema"]);
+ // Navicat exports OceanBase Oracle connections with Database="ORCL", but OceanBase resolves the target from the username.
+ const database = effectiveProfile.dbType === "sqlite" ? sqlitePath : effectiveProfile.dbType === "oceanbase-oracle" ? "" : getAny(node.values, ["database", "databaseName", "initialDatabase", "serviceName", "sid", "schema"]);
const isOracleLike = effectiveProfile.dbType === "oracle" || effectiveProfile.dbType === "oceanbase-oracle";
const oracleConnectionType = isOracleLike && getAny(node.values, ["sid"]) ? "sid" : isOracleLike ? "service_name" : undefined;
const username = getAny(node.values, ["user", "username", "userName", "uid"]) || profile.user;