diff --git a/all_test.go b/all_test.go index fd8d4a2..b69a162 100644 --- a/all_test.go +++ b/all_test.go @@ -1178,6 +1178,19 @@ func TestTimeScan(t *testing.T) { } } +// https://gitlab.com/cznic/sqlite/-/issues/49 +func TestTimeLocaltime(t *testing.T) { + db, err := sql.Open(driverName, "file::memory:") + if err != nil { + t.Fatal(err) + } + defer db.Close() + + if _, err := db.Exec("select datetime('now', 'localtime')"); err != nil { + t.Fatal(err) + } +} + // https://sqlite.org/lang_expr.html#varparam // https://gitlab.com/cznic/sqlite/-/issues/42 func TestBinding(t *testing.T) { diff --git a/sqlite.go b/sqlite.go index 269349f..1eca234 100644 --- a/sqlite.go +++ b/sqlite.go @@ -14,6 +14,7 @@ import ( "fmt" "io" "math" + "os" "reflect" "runtime" "strconv" @@ -119,6 +120,9 @@ var ( func init() { tls := libc.NewTLS() + + libc.SetEnviron(tls, os.Environ()) + if sqlite3.Xsqlite3_threadsafe(tls) == 0 { panic(fmt.Errorf("sqlite: thread safety configuration error")) }