fix(sqlite): validate ssh backup and query errors
This commit is contained in:
1 parent
e6f8b2187a
commit
9190554e50
58 files changed
+2815
-149
No files matched your search
@@ -13,6 +13,11 @@ describe("connection dialog scrolling", () => {
|
||||
expect(dialogSource).toMatch(/\.connection-dialog-content--config \.connection-form-body\s*\{[\s\S]*?align-content:\s*start;/);
|
||||
});
|
||||
|
||||
it("hides proxy and HTTP tunnel controls for SQLite", () => {
|
||||
expect(dialogSource).toContain('v-if="!sqliteSshOnlyTransport"');
|
||||
expect(dialogSource).toContain('v-if="!selectedLayerProfileId && !sqliteSshOnlyTransport"');
|
||||
});
|
||||
|
||||
it("keeps the transport form inside a shrinkable scroll viewport", () => {
|
||||
expect(dialogSource).toContain('<TabsContent v-if="canUseTransportLayers" value="transport" class="m-0 flex min-h-0 flex-1 flex-col overflow-hidden">');
|
||||
expect(dialogSource).toContain('class="connection-form-body grid min-h-0 flex-1 scroll-pb-6 gap-4 overflow-y-auto overflow-x-hidden pt-4 pr-2 pb-6"');
|
||||
|
||||
@@ -144,6 +144,7 @@ export const revealPathInFileManager = forward("revealPathInFileManager");
|
||||
export const deleteDatabaseBackupFiles = forward("deleteDatabaseBackupFiles");
|
||||
export const isSqliteDatabaseFile = forward("isSqliteDatabaseFile");
|
||||
export const backupSqliteDatabase = forward("backupSqliteDatabase");
|
||||
export const restoreSqliteDatabase = forward("restoreSqliteDatabase");
|
||||
export const syncSavedSqlDirectory = forward("syncSavedSqlDirectory");
|
||||
|
||||
// Schema
|
||||
|
||||
@@ -767,6 +767,10 @@ export async function backupSqliteDatabase(_connectionId: string, _destinationPa
|
||||
throw new Error("SQLite backup is only available in the desktop app.");
|
||||
}
|
||||
|
||||
export async function restoreSqliteDatabase(_connectionId: string, _sourcePath: string): Promise<void> {
|
||||
throw new Error("Remote SQLite restore is only available in the desktop app.");
|
||||
}
|
||||
|
||||
export async function syncSavedSqlDirectory(_request: SavedSqlSyncRequest): Promise<void> {
|
||||
throw new Error("SQL directory sync is only available in the desktop app.");
|
||||
}
|
||||
|
||||
@@ -2287,6 +2287,10 @@ export async function backupSqliteDatabase(connectionId: string, destinationPath
|
||||
return invoke("backup_sqlite_database", { connectionId, destinationPath });
|
||||
}
|
||||
|
||||
export async function restoreSqliteDatabase(connectionId: string, sourcePath: string): Promise<void> {
|
||||
return invoke("restore_sqlite_database", { connectionId, sourcePath });
|
||||
}
|
||||
|
||||
export async function syncSavedSqlDirectory(request: SavedSqlSyncRequest): Promise<void> {
|
||||
return invoke("sync_saved_sql_directory", { request });
|
||||
}
|
||||
|
||||
@@ -9,6 +9,16 @@ describe("DuckDB driver installation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("SQLite SSH worker installation", () => {
|
||||
it("requires the downloadable worker only for SQLite over SSH", () => {
|
||||
expect(agentDriverInstallKey("sqlite")).toBeUndefined();
|
||||
expect(showAgentDriverInstallHint("sqlite", [])).toBe(false);
|
||||
expect(agentDriverInstallKey("sqlite", undefined, { ssh: true })).toBe("sqlite-worker");
|
||||
expect(showAgentDriverInstallHint("sqlite", [], undefined, { ssh: true })).toBe(true);
|
||||
expect(showAgentDriverInstallHint("sqlite", [{ db_type: "sqlite-worker", installed: true }], undefined, { ssh: true })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("HiveServer2-compatible driver installation", () => {
|
||||
it("reuses the downloadable Hive driver", () => {
|
||||
expect(agentDriverInstallKey("impala")).toBe("hive");
|
||||
@@ -19,10 +29,10 @@ describe("HiveServer2-compatible driver installation", () => {
|
||||
});
|
||||
|
||||
describe("driverStoreFocusForInstallError", () => {
|
||||
it("focuses the missing agent driver for driver-not-installed errors", () => {
|
||||
expect(driverStoreFocusForInstallError("zookeeper driver is not installed. Please install it from the Driver Manager.", "zookeeper", undefined)).toEqual({
|
||||
it("focuses the SQLite SSH worker for remote SQLite driver errors", () => {
|
||||
expect(driverStoreFocusForInstallError("sqlite-worker driver is not installed. Please install it from the Driver Manager.", "sqlite", undefined)).toEqual({
|
||||
target: "driver",
|
||||
driver: "zookeeper",
|
||||
driver: "sqlite-worker",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ describe("AGENT_DRIVER_CATEGORY_MAP integrity", () => {
|
||||
"access",
|
||||
"duckdb",
|
||||
"h2",
|
||||
"sqlite-worker",
|
||||
// document
|
||||
"cassandra",
|
||||
"mongodb",
|
||||
|
||||
@@ -8,6 +8,14 @@ export interface AgentDriverInstallState {
|
||||
update_available?: boolean;
|
||||
}
|
||||
|
||||
export type AgentDriverInstallContext = {
|
||||
ssh?: boolean;
|
||||
};
|
||||
|
||||
export function connectionUsesSsh(config: { transport_layers?: Array<{ type?: string; enabled?: boolean }> } | undefined): boolean {
|
||||
return (config?.transport_layers ?? []).some((layer) => layer.enabled !== false && layer.type === "ssh");
|
||||
}
|
||||
|
||||
/** Returns whether a locally installed native Agent meets a required release. */
|
||||
export function hasInstalledAgentVersion(drivers: readonly AgentDriverInstallState[], driverKey: string, minimumVersion: string): boolean {
|
||||
const installedVersion = drivers.find((driver) => driver.db_type === driverKey && driver.installed)?.installed_version;
|
||||
@@ -23,7 +31,8 @@ export function hasInstalledAgentVersion(drivers: readonly AgentDriverInstallSta
|
||||
return installed[0] > minimum[0] || (installed[0] === minimum[0] && (installed[1] > minimum[1] || (installed[1] === minimum[1] && installed[2] >= minimum[2])));
|
||||
}
|
||||
|
||||
export function agentDriverInstallKey(dbType: DatabaseType | undefined, driverProfile?: string): string | undefined {
|
||||
export function agentDriverInstallKey(dbType: DatabaseType | undefined, driverProfile?: string, context?: AgentDriverInstallContext): string | undefined {
|
||||
if (dbType === "sqlite") return context?.ssh ? "sqlite-worker" : undefined;
|
||||
if (dbType === "kyuubi" || dbType === "impala") return "hive";
|
||||
if (dbType === "oracle") return "oracle";
|
||||
if (dbType === "h2") return "h2";
|
||||
@@ -39,23 +48,24 @@ export function agentDriverInstallKey(dbType: DatabaseType | undefined, driverPr
|
||||
return driverProfile && driverProfile !== dbType ? driverProfile : dbType;
|
||||
}
|
||||
|
||||
function usesManagedAgentDriver(dbType: DatabaseType | undefined, driverProfile?: string): boolean {
|
||||
function usesManagedAgentDriver(dbType: DatabaseType | undefined, driverProfile?: string, context?: AgentDriverInstallContext): boolean {
|
||||
if (dbType === "sqlite") return context?.ssh === true;
|
||||
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 (!usesManagedAgentDriver(dbType, driverProfile)) return false;
|
||||
const driverKey = agentDriverInstallKey(dbType, driverProfile);
|
||||
export function showAgentDriverInstallHint(dbType: DatabaseType | undefined, drivers: readonly AgentDriverInstallState[], driverProfile?: string, context?: AgentDriverInstallContext): boolean {
|
||||
if (!usesManagedAgentDriver(dbType, driverProfile, context)) return false;
|
||||
const driverKey = agentDriverInstallKey(dbType, driverProfile, context);
|
||||
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 (!usesManagedAgentDriver(dbType, driverProfile)) return false;
|
||||
const driverKey = agentDriverInstallKey(dbType, driverProfile);
|
||||
export function hasAgentDriverUpdate(dbType: DatabaseType | undefined, drivers: readonly AgentDriverInstallState[], driverProfile?: string, context?: AgentDriverInstallContext): boolean {
|
||||
if (!usesManagedAgentDriver(dbType, driverProfile, context)) return false;
|
||||
const driverKey = agentDriverInstallKey(dbType, driverProfile, context);
|
||||
return drivers.find((driver) => driver.db_type === driverKey)?.update_available === true;
|
||||
}
|
||||
|
||||
@@ -73,5 +83,6 @@ export type DriverStoreFocus = { target: "driver"; driver?: string } | { target:
|
||||
export function driverStoreFocusForInstallError(message: string, dbType?: DatabaseType, driverProfile?: string): DriverStoreFocus | null {
|
||||
if (message.includes("JRE") && message.includes("not installed")) return { target: "jre" };
|
||||
if (!message.includes("is not installed") && !message.includes("reinstall it from the Driver Manager")) return null;
|
||||
return { target: "driver", driver: agentDriverInstallKey(dbType, driverProfile) };
|
||||
if (message.includes("sqlite-worker")) return { target: "driver", driver: "sqlite-worker" };
|
||||
return { target: "driver", driver: agentDriverInstallKey(dbType, driverProfile, { ssh: dbType === "sqlite" }) };
|
||||
}
|
||||
@@ -25,6 +25,7 @@ export const AGENT_DRIVER_CATEGORY_MAP: Readonly<Record<string, DriverCategoryKe
|
||||
databricks: "analytics",
|
||||
db2: "sql",
|
||||
duckdb: "lightweight",
|
||||
"sqlite-worker": "lightweight",
|
||||
etcd: "registry_config",
|
||||
exasol: "analytics",
|
||||
firebird: "sql",
|
||||
|
||||
Reference in new issue
Block a user