fix(oracle): apply default orcl database
This commit is contained in:
2 files changed
+36
No files matched your search
@@ -774,6 +774,23 @@ mod tests {
|
||||
assert_eq!(params["sessionRole"], "metadata");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oracle_form_connections_use_orcl_when_database_is_omitted() {
|
||||
for (mode, expected_url) in [
|
||||
("service_name", "jdbc:oracle:thin:@//oracle.example.com:1521/ORCL"),
|
||||
("sid", "jdbc:oracle:thin:@oracle.example.com:1521:ORCL"),
|
||||
] {
|
||||
let mut cfg = config(DatabaseType::Oracle, None);
|
||||
cfg.oracle_connection_type = Some(mode.to_string());
|
||||
let database = cfg.effective_database().unwrap_or("");
|
||||
|
||||
let params = agent_connect_params(&cfg, "oracle.example.com", 1521, database).unwrap();
|
||||
|
||||
assert_eq!(params["database"], "ORCL");
|
||||
assert_eq!(params["connection_string"], expected_url);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn structured_hive_uses_current_url_params_for_zookeeper_detection() {
|
||||
let mut cfg = config(DatabaseType::Hive, Some("default"));
|
||||
|
||||
@@ -856,6 +856,11 @@ impl ConnectionConfig {
|
||||
DatabaseType::Highgo => Some("highgo"),
|
||||
DatabaseType::Uxdb => Some("uxdb"),
|
||||
DatabaseType::Yashandb => Some("yasdb"),
|
||||
DatabaseType::Oracle
|
||||
if !self.oracle_connection_type.as_deref().is_some_and(|mode| mode.eq_ignore_ascii_case("tns")) =>
|
||||
{
|
||||
Some("ORCL")
|
||||
}
|
||||
DatabaseType::Oscar => Some("osrdb"),
|
||||
DatabaseType::Firebird => Some("employee"),
|
||||
DatabaseType::H2 => Some("test"),
|
||||
@@ -2832,6 +2837,20 @@ mod tests {
|
||||
assert_eq!(config.effective_database(), Some("postgres"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oracle_database_defaults_to_orcl_except_for_tns_aliases() {
|
||||
let mut config = mysql_config("system", "oracle", None);
|
||||
config.db_type = DatabaseType::Oracle;
|
||||
|
||||
for mode in [None, Some("service_name"), Some("sid")] {
|
||||
config.oracle_connection_type = mode.map(str::to_string);
|
||||
assert_eq!(config.effective_database(), Some("ORCL"));
|
||||
}
|
||||
|
||||
config.oracle_connection_type = Some("tns".to_string());
|
||||
assert_eq!(config.effective_database(), None);
|
||||
}
|
||||
|
||||
fn mongodb_config(username: &str, password: &str, database: Option<&str>) -> ConnectionConfig {
|
||||
let mut config = mysql_config(username, password, database);
|
||||
config.db_type = DatabaseType::MongoDb;
|
||||
|
||||
Reference in new issue
Block a user