Skip to content

Commit

Permalink
Fix sqlite initialization flags
Browse files Browse the repository at this point in the history
  • Loading branch information
marco6 committed Oct 8, 2024
1 parent 72d769f commit a05eb38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/kine/drivers/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func NewVariant(ctx context.Context, driverName, dataSourceName string, connecti
}
logrus.Printf("DriverName is %s.", driverName)

if dataSourceName == "" {
if opts.dsn == "" {
if err := os.MkdirAll("./db", 0700); err != nil {
return nil, nil, err
}
dataSourceName = "./db/state.db?_journal=WAL&cache=shared"
opts.dsn = "./db/state.db?_journal=WAL&_synchronous=FULL&_foreign_keys=1"
}

dialect, err := generic.Open(ctx, driverName, opts.dsn, connectionPoolConfig, "?", false)
Expand Down Expand Up @@ -212,7 +212,7 @@ func parseOpts(dsn string) (opts, error) {
}
result.watchQueryTimeout = d
default:
return opts{}, fmt.Errorf("unknown option %s=%v", k, vs)
continue
}
delete(values, k)
}
Expand Down
2 changes: 1 addition & 1 deletion test/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func newKineServer(ctx context.Context, tb testing.TB, options *kineOptions) *ki
}

func startSqlite(_ context.Context, tb testing.TB, dir string) (*endpoint.Config, *sql.DB) {
dbPath := path.Join(dir, "data.db")
dbPath := path.Join(dir, "data.db") + "?_journal=WAL&_synchronous=FULL&_foreign_keys=1"

db, err := sql.Open("sqlite3", dbPath)
if err != nil {
Expand Down

0 comments on commit a05eb38

Please sign in to comment.