fix(mongodb): install legacy driver during connection test

This commit is contained in:
zipg authored and GitHub committed 2026-08-14 14:45:35 +08:00
1 parent b6c4a0be0f
commit 325127419f
8 files changed
+64 -12

No files matched your search

@@ -37,15 +37,22 @@ export function agentDriverInstallKey(dbType: DatabaseType | undefined, driverPr
return driverProfile && driverProfile !== dbType ? driverProfile : dbType;
}
function usesManagedAgentDriver(dbType: DatabaseType | undefined, driverProfile?: string): boolean {
if (supportsDriverManagement(dbType)) return true;
if (dbType !== "mongodb") return false;
const profile = driverProfile?.trim().toLowerCase();
return profile === "mongodb-legacy" || profile === "mongodb_legacy" || profile === "legacy";
}
export function showAgentDriverInstallHint(dbType: DatabaseType | undefined, drivers: readonly AgentDriverInstallState[], driverProfile?: string): boolean {
if (!supportsDriverManagement(dbType)) return false;
if (!usesManagedAgentDriver(dbType, driverProfile)) return false;
const driverKey = agentDriverInstallKey(dbType, driverProfile);
if (!driverKey) return false;
return drivers.find((driver) => driver.db_type === driverKey)?.installed !== true;
}
export function hasAgentDriverUpdate(dbType: DatabaseType | undefined, drivers: readonly AgentDriverInstallState[], driverProfile?: string): boolean {
if (!supportsDriverManagement(dbType)) return false;
if (!usesManagedAgentDriver(dbType, driverProfile)) return false;
const driverKey = agentDriverInstallKey(dbType, driverProfile);
return drivers.find((driver) => driver.db_type === driverKey)?.update_available === true;
}