Fix SQLite file:// URI scheme to prevent query params in filename (bd-c54b)

This commit is contained in:
Steve Yegge
2025-11-03 16:08:34 -08:00
parent 30eccde11f
commit a0eb19066a
2 changed files with 4 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@@ -49,13 +49,8 @@ func New(path string) (*SQLiteStorage, error) {
// _pragma=foreign_keys(ON) enforces foreign key constraints // _pragma=foreign_keys(ON) enforces foreign key constraints
// _pragma=busy_timeout(30000) means wait up to 30 seconds for locks instead of failing immediately // _pragma=busy_timeout(30000) means wait up to 30 seconds for locks instead of failing immediately
// _time_format=sqlite enables automatic parsing of DATETIME columns to time.Time // _time_format=sqlite enables automatic parsing of DATETIME columns to time.Time
// Note: For shared memory URLs, additional params need to be added with & not ? // Use file: URI scheme to properly separate file path from query parameters
connStr := dbPath connStr := "file:" + dbPath + "?_pragma=journal_mode(WAL)&_pragma=foreign_keys(ON)&_pragma=busy_timeout(30000)&_time_format=sqlite"
if strings.Contains(dbPath, "?") {
connStr += "&_pragma=journal_mode(WAL)&_pragma=foreign_keys(ON)&_pragma=busy_timeout(30000)&_time_format=sqlite"
} else {
connStr += "?_pragma=journal_mode(WAL)&_pragma=foreign_keys(ON)&_pragma=busy_timeout(30000)&_time_format=sqlite"
}
db, err := sql.Open("sqlite3", connStr) db, err := sql.Open("sqlite3", connStr)
if err != nil { if err != nil {