fix(kingbase): keep legacy empty-database default
This commit is contained in:
2 files changed
+31
-4
No files matched your search
@@ -929,6 +929,26 @@ mod tests {
|
|||||||
assert_eq!(params["connection_string"], "jdbc:vastbase://vastbase.example.com:5432/postgres");
|
assert_eq!(params["connection_string"], "jdbc:vastbase://vastbase.example.com:5432/postgres");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn kingbase_agent_params_keep_legacy_postgres_default_when_database_is_empty() {
|
||||||
|
let cfg = config(DatabaseType::Kingbase, None);
|
||||||
|
|
||||||
|
let params = agent_connect_params(&cfg, "kingbase.example.com", 54321, "").unwrap();
|
||||||
|
|
||||||
|
assert_eq!(params["database"], "postgres");
|
||||||
|
assert_eq!(params["connection_string"], "jdbc:kingbase8://kingbase.example.com:54321/postgres");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn kingbase_agent_params_preserve_explicit_database() {
|
||||||
|
let cfg = config(DatabaseType::Kingbase, Some("application"));
|
||||||
|
|
||||||
|
let params = agent_connect_params(&cfg, "kingbase.example.com", 54321, "application").unwrap();
|
||||||
|
|
||||||
|
assert_eq!(params["database"], "application");
|
||||||
|
assert_eq!(params["connection_string"], "jdbc:kingbase8://kingbase.example.com:54321/application");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uxdb_agent_params_use_vendor_jdbc_url() {
|
fn uxdb_agent_params_use_vendor_jdbc_url() {
|
||||||
let cfg = config(DatabaseType::Uxdb, Some("uxdb"));
|
let cfg = config(DatabaseType::Uxdb, Some("uxdb"));
|
||||||
|
|||||||
@@ -857,7 +857,10 @@ impl ConnectionConfig {
|
|||||||
DatabaseType::Rqlite | DatabaseType::Turso | DatabaseType::CloudflareD1 => Some("main"),
|
DatabaseType::Rqlite | DatabaseType::Turso | DatabaseType::CloudflareD1 => Some("main"),
|
||||||
DatabaseType::Gaussdb | DatabaseType::OpenGauss => Some("postgres"),
|
DatabaseType::Gaussdb | DatabaseType::OpenGauss => Some("postgres"),
|
||||||
DatabaseType::Kwdb => Some("defaultdb"),
|
DatabaseType::Kwdb => Some("defaultdb"),
|
||||||
DatabaseType::Vastbase => Some("postgres"),
|
// Keep saved Kingbase connections from before the database field became
|
||||||
|
// required working after upgrade. New and edited desktop connections
|
||||||
|
// still require an explicit existing database in the connection form.
|
||||||
|
DatabaseType::Kingbase | DatabaseType::Vastbase => Some("postgres"),
|
||||||
DatabaseType::Highgo => Some("highgo"),
|
DatabaseType::Highgo => Some("highgo"),
|
||||||
DatabaseType::Uxdb => Some("uxdb"),
|
DatabaseType::Uxdb => Some("uxdb"),
|
||||||
DatabaseType::Yashandb => Some("yasdb"),
|
DatabaseType::Yashandb => Some("yasdb"),
|
||||||
@@ -3444,13 +3447,17 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn kingbase_empty_database_has_no_default() {
|
fn kingbase_empty_database_uses_legacy_postgres_default() {
|
||||||
let mut config = mysql_config("SYSTEM", "secret", None);
|
let mut config = mysql_config("SYSTEM", "secret", None);
|
||||||
config.db_type = DatabaseType::Kingbase;
|
config.db_type = DatabaseType::Kingbase;
|
||||||
config.port = 54321;
|
config.port = 54321;
|
||||||
|
|
||||||
assert_eq!(config.effective_database(), None);
|
assert_eq!(config.effective_database(), Some("postgres"));
|
||||||
assert_eq!(config.connection_url(), "kingbase://SYSTEM:secret@10.1.2.3:54321");
|
assert_eq!(config.connection_url(), "kingbase://SYSTEM:secret@10.1.2.3:54321/postgres");
|
||||||
|
|
||||||
|
config.database = Some("application".to_string());
|
||||||
|
assert_eq!(config.effective_database(), Some("application"));
|
||||||
|
assert_eq!(config.connection_url(), "kingbase://SYSTEM:secret@10.1.2.3:54321/application");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in new issue
Block a user