fix: use execcontext in db

This commit is contained in:
2026-06-11 14:49:57 +02:00
parent 6ba387bb6a
commit acabd50970
3 changed files with 5 additions and 4 deletions

View File

@@ -60,7 +60,7 @@ func openCommandPaletteTestDB(t *testing.T) *sql.DB {
} }
t.Cleanup(func() { _ = sqlDB.Close() }) t.Cleanup(func() { _ = sqlDB.Close() })
_, err = sqlDB.Exec(` _, err = sqlDB.ExecContext(context.Background(), `
CREATE TABLE anime ( CREATE TABLE anime (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
title_original TEXT NOT NULL, title_original TEXT NOT NULL,

View File

@@ -1,6 +1,7 @@
package db package db
import ( import (
"context"
"database/sql" "database/sql"
"fmt" "fmt"
@@ -17,7 +18,7 @@ func Open(dbFile string) (*sql.DB, error) {
return nil, fmt.Errorf("failed to open db: %w", err) return nil, fmt.Errorf("failed to open db: %w", err)
} }
// WAL improves concurrency between readers and writers. // WAL improves concurrency between readers and writers.
_, _ = db.Exec("PRAGMA journal_mode=WAL;") _, _ = db.ExecContext(context.Background(), "PRAGMA journal_mode=WAL;")
_, _ = db.Exec("PRAGMA busy_timeout=5000;") _, _ = db.ExecContext(context.Background(), "PRAGMA busy_timeout=5000;")
return db, nil return db, nil
} }

View File

@@ -16,7 +16,7 @@ func TestGetUserWatchlistAnimeIDsFiltersRequestedIDs(t *testing.T) {
} }
defer func() { _ = sqlDB.Close() }() defer func() { _ = sqlDB.Close() }()
_, err = sqlDB.Exec(` _, err = sqlDB.ExecContext(context.Background(), `
CREATE TABLE watch_list_entry ( CREATE TABLE watch_list_entry (
id TEXT PRIMARY KEY, id TEXT PRIMARY KEY,
user_id TEXT NOT NULL, user_id TEXT NOT NULL,