Summary
turso db import (and db create --from-file) rejects valid WAL-mode databases when the system sqlite3 is version 3.50 or newer, because the .mode line output format changed from key = value to key: value.
Tested with turso v1.0.20 and sqlite3 3.52.0.
Reproduction
sqlite3 mydb.db "PRAGMA journal_mode=WAL; PRAGMA wal_checkpoint(truncate);"
turso db import mydb.db
# Error: database is not in WAL mode. Set it with 'sqlite3 mydb.db 'PRAGMA journal_mode = WAL'
The DB is in WAL mode. Running the exact check command turso uses confirms it:
$ sqlite3 -list mydb.db ".mode line" \
"select journal_mode as j, page_size as p, auto_vacuum as a, encoding as e \
from pragma_journal_mode, pragma_page_size, pragma_auto_vacuum, pragma_encoding;"
j: wal
p: 4096
a: 0
e: UTF-8
But internal/cmd/group_flag.go checks for the old format:
if !strings.Contains(settings, "j = wal") { ... }
if !strings.Contains(settings, "p = 4096") { ... }
if !strings.Contains(settings, "a = 0") { ... }
if !strings.Contains(settings, "e = UTF-8") { ... }
All four checks fail on sqlite3 ≥ 3.50.
v1.0.20's "explicitly use -list" fix (#1029) addresses a different sqlite3 default-mode change, not this one — .mode line itself was reformatted.
Suggested fix
Parse each pragma_* value with its own one-shot query (e.g. sqlite3 -batch -noheader file "select journal_mode from pragma_journal_mode") and compare the trimmed output, instead of string-matching against a multi-pragma .mode line dump. That avoids dependence on the formatting of any sqlite3 output mode.
Workaround
PATH-shim sqlite3 to rewrite the separator:
mkdir -p /tmp/shim && cat > /tmp/shim/sqlite3 <<'EOF'
#!/usr/bin/env bash
/usr/bin/sqlite3 "$@" | sed 's/^\([a-z]\): /\1 = /'
EOF
chmod +x /tmp/shim/sqlite3
PATH=/tmp/shim:$PATH turso db import mydb.db
Summary
turso db import(anddb create --from-file) rejects valid WAL-mode databases when the systemsqlite3is version 3.50 or newer, because the.mode lineoutput format changed fromkey = valuetokey: value.Tested with
turso v1.0.20andsqlite3 3.52.0.Reproduction
The DB is in WAL mode. Running the exact check command turso uses confirms it:
But
internal/cmd/group_flag.gochecks for the old format:All four checks fail on sqlite3 ≥ 3.50.
v1.0.20's "explicitly use -list" fix (#1029) addresses a different sqlite3 default-mode change, not this one —
.mode lineitself was reformatted.Suggested fix
Parse each
pragma_*value with its own one-shot query (e.g.sqlite3 -batch -noheader file "select journal_mode from pragma_journal_mode") and compare the trimmed output, instead of string-matching against a multi-pragma.mode linedump. That avoids dependence on the formatting of any sqlite3 output mode.Workaround
PATH-shim
sqlite3to rewrite the separator: