diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue index 067986810..f4b45d655 100644 --- a/apps/desktop/src/components/connection/ConnectionDialog.vue +++ b/apps/desktop/src/components/connection/ConnectionDialog.vue @@ -30,6 +30,7 @@ import { MQ_PINNED_VERSION_OPTIONS, pinnedVersionToSelection, selectionToPinnedV import { mongodbAuthFailureHint, mongoUrlParam, setMongoUrlParam } from "@/lib/mongoConnectionOptions"; import { copyToClipboard } from "@/lib/clipboard"; import { showAgentDriverInstallHint, type AgentDriverInstallState } from "@/lib/agentDriverInstallHint"; +import { prestoSqlBuiltinDriverPaths } from "@/lib/prestoSqlBuiltinDriver"; import { ArrowLeft, ArrowDown, ArrowUp, CheckSquare, ChevronRight, CircleHelp, Copy, ExternalLink, FilePlus2, FolderOpen, GripVertical, Grid3X3, KeyRound, Link2, List, ListFilter, Loader2, Pipette, Plus, Search, ShieldCheck, Square, Trash2 } from "@lucide/vue"; import { buildDraftVisibleDatabasesConnectionId, connectionCanChooseVisibleDatabases, initialVisibleDatabaseSelection, visibleDatabaseSelectionIsStale } from "@/lib/connectionVisibleDatabases"; import { canSaveVisibleDatabaseSelection, filterDatabaseNamesForConnection, isSystemDatabaseName, normalizeVisibleDatabaseSelection } from "@/lib/visibleDatabases"; @@ -1390,6 +1391,7 @@ function connectionConfigForSubmit(id: string): ConnectionConfig { } else if (config.db_type === "prestosql") { config.connection_string = undefined; config.jdbc_driver_class = config.jdbc_driver_class?.trim() || "io.prestosql.jdbc.PrestoDriver"; + applyPrestoSqlBuiltinDriverPathsIfAvailable(); } config.jdbc_driver_class = config.jdbc_driver_class?.trim() || undefined; config.jdbc_driver_paths = jdbcDriverPathsInput.value @@ -2256,6 +2258,7 @@ async function loadJdbcDrivers() { const [drivers, bundles] = await Promise.all([api.listJdbcDrivers(), api.listJdbcMavenBundles()]); jdbcDrivers.value = drivers; jdbcMavenBundles.value = bundles; + applyPrestoSqlBuiltinDriverPathsIfAvailable(); } catch { jdbcDrivers.value = []; jdbcMavenBundles.value = []; @@ -2287,6 +2290,15 @@ function addJdbcDriverPaths(paths: string[]) { jdbcDriverPathsInput.value = Array.from(new Set([...existing, ...paths])).join("\n"); } +function applyPrestoSqlBuiltinDriverPathsIfAvailable() { + if (form.value.db_type !== "prestosql" || jdbcManualClasspathCount.value > 0) return; + const paths = prestoSqlBuiltinDriverPaths(jdbcMavenBundles.value); + if (paths.length === 0) return; + addJdbcDriverPaths(paths); + selectedJdbcDriverPath.value = jdbcDriverSelectItems.value.find((item) => paths.every((path) => item.paths.includes(path)))?.id ?? ""; + jdbcManualClasspathOpen.value = false; +} + function onJdbcDriverSelect(id: any) { if (typeof id !== "string" || !id) return; const item = jdbcDriverSelectItemById.value.get(id); diff --git a/apps/desktop/src/lib/__tests__/connectionAttemptTimeout.spec.ts b/apps/desktop/src/lib/__tests__/connectionAttemptTimeout.spec.ts index caa1667e0..543f72c24 100644 --- a/apps/desktop/src/lib/__tests__/connectionAttemptTimeout.spec.ts +++ b/apps/desktop/src/lib/__tests__/connectionAttemptTimeout.spec.ts @@ -14,6 +14,10 @@ describe("connectionAttemptTimeout", () => { expect(connectionAttemptTimeoutMs({ db_type: "oracle", connect_timeout_secs: 5, transport_layers: [] })).toBe(AGENT_DRIVER_MIN_CONNECT_TIMEOUT_SECS * 1000 + CONNECTION_ATTEMPT_TIMEOUT_BUFFER_MS); }); + it("uses the startup floor for PrestoSQL JDBC plugin connections", () => { + expect(connectionAttemptTimeoutMs({ db_type: "prestosql", connect_timeout_secs: 5, transport_layers: [] })).toBe(AGENT_DRIVER_MIN_CONNECT_TIMEOUT_SECS * 1000 + CONNECTION_ATTEMPT_TIMEOUT_BUFFER_MS); + }); + it("uses a 30s Access agent startup floor", () => { expect(connectionAttemptTimeoutMs({ db_type: "access", connect_timeout_secs: 5, transport_layers: [] })).toBe(ACCESS_AGENT_MIN_CONNECT_TIMEOUT_SECS * 1000 + CONNECTION_ATTEMPT_TIMEOUT_BUFFER_MS); }); diff --git a/apps/desktop/src/lib/__tests__/prestoSqlBuiltinDriver.spec.ts b/apps/desktop/src/lib/__tests__/prestoSqlBuiltinDriver.spec.ts index 8b0cefded..2561499f7 100644 --- a/apps/desktop/src/lib/__tests__/prestoSqlBuiltinDriver.spec.ts +++ b/apps/desktop/src/lib/__tests__/prestoSqlBuiltinDriver.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { PRESTOSQL_JDBC_DRIVER_COORDINATE, prestoSqlBuiltinDriverRow, prestoSqlMavenBundle } from "@/lib/prestoSqlBuiltinDriver"; +import { PRESTOSQL_JDBC_DRIVER_COORDINATE, prestoSqlBuiltinDriverPaths, prestoSqlBuiltinDriverRow, prestoSqlMavenBundle } from "@/lib/prestoSqlBuiltinDriver"; import type { JdbcMavenBundleInfo } from "@/types/database"; function bundle(coordinate: string, version = "350"): JdbcMavenBundleInfo { @@ -43,6 +43,7 @@ describe("prestoSqlBuiltinDriver", () => { const row = prestoSqlBuiltinDriverRow([bundle("com.mysql:mysql-connector-j:9.2.0"), installed]); expect(prestoSqlMavenBundle([installed])?.id).toBe(installed.id); + expect(prestoSqlBuiltinDriverPaths([installed])).toEqual(["drivers/jdbc/presto-jdbc-350.jar"]); expect(row.installed).toBe(true); expect(row.installed_version).toBe("350"); }); diff --git a/apps/desktop/src/lib/connectionAttemptTimeout.ts b/apps/desktop/src/lib/connectionAttemptTimeout.ts index 1d7cf5fa2..279e35cc3 100644 --- a/apps/desktop/src/lib/connectionAttemptTimeout.ts +++ b/apps/desktop/src/lib/connectionAttemptTimeout.ts @@ -6,7 +6,7 @@ export const AGENT_DRIVER_MIN_CONNECT_TIMEOUT_SECS = 30; export const ACCESS_AGENT_MIN_CONNECT_TIMEOUT_SECS = 30; const DEFAULT_CONNECT_TIMEOUT_SECS = 10; -const AGENT_DRIVER_TYPES = new Set([ +const DRIVER_STARTUP_FLOOR_TYPES = new Set([ "dameng", "kingbase", "highgo", @@ -49,7 +49,7 @@ function positiveSeconds(value: unknown, fallback: number): number { export function connectionAttemptTimeoutMs(config: Pick & Partial>): number { const baseTimeoutSecs = positiveSeconds(config.connect_timeout_secs, DEFAULT_CONNECT_TIMEOUT_SECS); const agentMinTimeoutSecs = config.db_type === "access" ? ACCESS_AGENT_MIN_CONNECT_TIMEOUT_SECS : AGENT_DRIVER_MIN_CONNECT_TIMEOUT_SECS; - const timeouts = [AGENT_DRIVER_TYPES.has(config.db_type as DatabaseType) ? Math.max(baseTimeoutSecs, agentMinTimeoutSecs) : baseTimeoutSecs]; + const timeouts = [DRIVER_STARTUP_FLOOR_TYPES.has(config.db_type as DatabaseType) ? Math.max(baseTimeoutSecs, agentMinTimeoutSecs) : baseTimeoutSecs]; for (const layer of config.transport_layers ?? []) { if (layer.type === "ssh") { timeouts.push(positiveSeconds(layer.connect_timeout_secs, DEFAULT_CONNECT_TIMEOUT_SECS)); diff --git a/apps/desktop/src/lib/prestoSqlBuiltinDriver.ts b/apps/desktop/src/lib/prestoSqlBuiltinDriver.ts index c76a9a653..cdfc00807 100644 --- a/apps/desktop/src/lib/prestoSqlBuiltinDriver.ts +++ b/apps/desktop/src/lib/prestoSqlBuiltinDriver.ts @@ -10,6 +10,10 @@ export function prestoSqlMavenBundle(bundles: JdbcMavenBundleInfo[]): JdbcMavenB return bundles.find((bundle) => bundle.coordinate === PRESTOSQL_JDBC_DRIVER_COORDINATE); } +export function prestoSqlBuiltinDriverPaths(bundles: JdbcMavenBundleInfo[]): string[] { + return (prestoSqlMavenBundle(bundles)?.artifacts ?? []).map((artifact) => artifact.path).filter(Boolean); +} + export function prestoSqlBuiltinDriverRow(bundles: JdbcMavenBundleInfo[]): AgentDriverInfo { const installedBundle = prestoSqlMavenBundle(bundles); return {