From 07b3d6d5734445dc10c843704f06c4ffed470a2b Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Fri, 4 Sep 2026 14:25:01 +0200 Subject: [PATCH] fix: Let configured file storage reach SQLite on WASI --- Sources/SQLiteKit/SQLiteConnectionSource.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/SQLiteKit/SQLiteConnectionSource.swift b/Sources/SQLiteKit/SQLiteConnectionSource.swift index dbffeae..1d7a696 100644 --- a/Sources/SQLiteKit/SQLiteConnectionSource.swift +++ b/Sources/SQLiteKit/SQLiteConnectionSource.swift @@ -30,9 +30,19 @@ public struct SQLiteConnectionSource: ConnectionPoolSource, Sendable { private var connectionStorage: SQLiteConnection.Storage { #if os(WASI) - // NOTE: For WASI platforms, file urls and paths cause runtime errors currently. Using - // in-memory connection only as a workaround. - .memory + // On WASI, pass the configured storage through directly: + // - `.file` works (sqlite over a preopened directory); pass the raw + // configured path rather than routing through `urlForSQLite`. + // - `.memory` stays a true in-memory database. The temp-file emulation + // of shared in-memory databases (see `urlForSQLite` below) requires a + // usable temporary directory, which WASI hosts do not generally + // preopen. + switch self.configuration.storage { + case .memory: + .memory + case .file(let path): + .file(path: path) + } #else .file(path: self.actualURL.absoluteString) #endif