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(transfer): detect OceanBase Oracle JDBC profile

t8y2d5dcdabd22e0
diff --git a/crates/dbx-core/src/data/transfer.rs b/crates/dbx-core/src/data/transfer.rs
index dbdcd04e28..1f0290dbbf 100644
--- a/crates/dbx-core/src/data/transfer.rs
+++ b/crates/dbx-core/src/data/transfer.rs
@@ -6350,6 +6350,12 @@ fn effective_transfer_database_type(config: &ConnectionConfig) -> DatabaseType {
if config.db_type != DatabaseType::Jdbc {
return config.db_type;
}
+ // The OceanBase JDBC URL and driver class are shared by MySQL and Oracle
+ // compatibility modes, so neither is a safe mode discriminator. The
+ // connection form persists this explicit profile only for Oracle mode.
+ if config.driver_profile.as_deref().is_some_and(|profile| profile.trim().eq_ignore_ascii_case("oceanbase-oracle")) {
+ return DatabaseType::OceanbaseOracle;
+ }
if config.driver_profile.as_deref().is_some_and(|profile| profile.eq_ignore_ascii_case("gbase8s")) {
return DatabaseType::Jdbc;
}
@@ -16202,6 +16208,68 @@ SELECT 1 FROM dual"#
assert!(!sql.contains("),\n("));
}
+ #[test]
+ fn oceanbase_oracle_jdbc_profile_routes_create_table_through_oracle_mode() {
+ let config = jdbc_transfer_config(
+ "jdbc:oceanbase://localhost:2883/ORCL",
+ "com.oceanbase.jdbc.Driver",
+ "OceanBase-Oracle",
+ );
+ let target_db = effective_transfer_database_type(&config);
+
+ assert_eq!(target_db, DatabaseType::OceanbaseOracle);
+
+ let ddl = generate_create_table_ddl(
+ &[
+ test_column("INSUPROKEY", "VARCHAR2(36 BYTE)"),
+ test_column("PREMIUM", "NUMBER(14,2)"),
+ test_column("DETAIL", "CLOB"),
+ ],
+ "PRPDINSURANCEPLANPROM",
+ "CPRPALL",
+ "CPRPALL",
+ &target_db,
+ &DatabaseType::Oracle,
+ None,
+ None,
+ );
+
+ assert_eq!(
+ ddl,
+ "CREATE TABLE \"CPRPALL\".\"PRPDINSURANCEPLANPROM\" (\n \"INSUPROKEY\" VARCHAR(36 byte),\n \"PREMIUM\" DECIMAL(14,2),\n \"DETAIL\" CLOB\n)"
+ );
+ }
+
+ #[test]
+ fn oceanbase_jdbc_url_without_oracle_profile_stays_generic() {
+ for profile in ["", "oceanbase"] {
+ let config =
+ jdbc_transfer_config("jdbc:oceanbase://localhost:2883/test", "com.oceanbase.jdbc.Driver", profile);
+ let target_db = effective_transfer_database_type(&config);
+
+ assert_eq!(target_db, DatabaseType::Jdbc, "profile: {profile}");
+
+ let ddl = generate_create_table_ddl(
+ &[test_column("INSUPROKEY", "VARCHAR2(36 BYTE)"), test_column("PREMIUM", "NUMBER(14,2)")],
+ "PRPDINSURANCEPLANPROM",
+ "CPRPALL",
+ "CPRPALL",
+ &target_db,
+ &DatabaseType::Oracle,
+ None,
+ None,
+ );
+ assert!(ddl.starts_with("CREATE TABLE IF NOT EXISTS "), "profile {profile}: {ddl}");
+ assert!(ddl.contains("\"INSUPROKEY\" VARCHAR(36)"), "profile {profile}: {ddl}");
+ assert!(ddl.contains("\"PREMIUM\" NUMERIC"), "profile {profile}: {ddl}");
+ }
+
+ let mut mysql_mode =
+ jdbc_transfer_config("jdbc:oceanbase://localhost:2883/test", "com.oceanbase.jdbc.Driver", "oceanbase");
+ mysql_mode.db_type = DatabaseType::Mysql;
+ assert_eq!(effective_transfer_database_type(&mysql_mode), DatabaseType::Mysql);
+ }
+
#[test]
fn non_oracle_jdbc_url_keeps_multi_row_values_insert() {
let config = jdbc_transfer_config("jdbc:mysql://localhost:3306/dbx_test", "com.mysql.cj.jdbc.Driver", "");