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(oracle): preserve custom jdbc endpoint

t8y2c851de795d1f
diff --git a/crates/dbx-core/src/agent_connection.rs b/crates/dbx-core/src/agent_connection.rs
index ca8767e0ce..eb10f16c74 100644
--- a/crates/dbx-core/src/agent_connection.rs
+++ b/crates/dbx-core/src/agent_connection.rs
@@ -78,7 +78,11 @@ pub fn mongo_legacy_error_with_auth_hint(err: &str) -> String {
fn oracle_jdbc_connection_string(config: &ConnectionConfig, host: &str, port: u16, database: &str) -> String {
if let Some(connection_string) = config.connection_string.as_deref().filter(|value| !value.trim().is_empty()) {
- return crate::models::connection::rewrite_jdbc_url_host(connection_string.trim(), host, port);
+ let connection_string = connection_string.trim();
+ if host == config.host && port == config.port {
+ return connection_string.to_string();
+ }
+ return crate::models::connection::rewrite_jdbc_url_host(connection_string, host, port);
}
let database = database.trim();
@@ -291,6 +295,24 @@ mod tests {
);
}
+ #[test]
+ fn oracle_url_preserves_custom_jdbc_descriptor_without_forwarding() {
+ let mut cfg = config(DatabaseType::Oracle, Some("ORCL"));
+ cfg.host = "form-host.example.com".to_string();
+ cfg.port = 1521;
+ cfg.connection_string = Some(
+ "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=descriptor-host.example.com)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=ORCL)))"
+ .to_string(),
+ );
+
+ let params = agent_connect_params(&cfg, "form-host.example.com", 1521, "ORCL");
+
+ assert_eq!(
+ params["connection_string"],
+ "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=descriptor-host.example.com)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=ORCL)))"
+ );
+ }
+
#[test]
fn oracle_listener_errors_can_switch_descriptor() {
let mut cfg = config(DatabaseType::Oracle, Some("ORCL"));