fix(kingbase): keep legacy empty-database default

This commit is contained in:
zipg authored and GitHub committed 2026-09-02 20:29:03 +08:00
1 parent b9b9d0bd31
commit f3258fe08a
2 files changed
+31 -4

No files matched your search

+11 -4
View File
@@ -857,7 +857,10 @@ impl ConnectionConfig {
DatabaseType::Rqlite | DatabaseType::Turso | DatabaseType::CloudflareD1 => Some("main"),
DatabaseType::Gaussdb | DatabaseType::OpenGauss => Some("postgres"),
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::Uxdb => Some("uxdb"),
DatabaseType::Yashandb => Some("yasdb"),
@@ -3444,13 +3447,17 @@ mod tests {
}
#[test]
fn kingbase_empty_database_has_no_default() {
fn kingbase_empty_database_uses_legacy_postgres_default() {
let mut config = mysql_config("SYSTEM", "secret", None);
config.db_type = DatabaseType::Kingbase;
config.port = 54321;
assert_eq!(config.effective_database(), None);
assert_eq!(config.connection_url(), "kingbase://SYSTEM:secret@10.1.2.3:54321");
assert_eq!(config.effective_database(), Some("postgres"));
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]