Skip to content

fix: use SqliteConnectOptions for reliable WAL mode database opening#80

Merged
debba merged 2 commits intodebba:mainfrom
GreenBeret9:fix/sqlite-wal-open-mode
Mar 9, 2026
Merged

fix: use SqliteConnectOptions for reliable WAL mode database opening#80
debba merged 2 commits intodebba:mainfrom
GreenBeret9:fix/sqlite-wal-open-mode

Conversation

@GreenBeret9
Copy link

Summary

  • Switch SQLite pool creation from bare URL .connect(&url) to SqliteConnectOptions with .connect_with(options) — consistent with how PostgreSQL connections are already handled
  • Set read_only(true) since Tabularis is a database viewer/browser
  • Set journal_mode(Wal) explicitly so sqlx handles WAL journal files (-wal, -shm) correctly

Problem

Opening a SQLite database that uses WAL journal mode fails with:

error returned from database: (code: 14) unable to open database file

This happens because the bare sqlite:// URL connection doesn't configure journal mode handling. On Windows especially, if -wal and -shm sidecar files exist, the default connection mode can fail to open the database.

Test plan

  • Open a SQLite database created with WAL journal mode (has -wal and -shm files alongside the .db file)
  • Verify the database opens successfully and tables/data are visible
  • Verify existing non-WAL SQLite databases still open correctly

Opening SQLite databases in WAL journal mode fails with "unable to open
database file" (code 14) because the bare URL connection doesn't
configure journal mode handling.

Switch to SqliteConnectOptions (consistent with the PostgreSQL driver
pattern) with read_only(true) and explicit WAL journal mode, fixing
the issue on Windows and when -wal/-shm files are present.
let url = format!("sqlite://{}", params.database);
SqliteConnectOptions::from_str(&url)
.unwrap_or_else(|_| SqliteConnectOptions::new().filename(&params.database))
.read_only(true)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: .read_only(true) prevents all write operations on SQLite databases

This setting makes SQLite connections read-only, which means users cannot:

  • Create tables or indexes
  • Insert, update, or delete data
  • Execute any DDL or DML write operations

For a database management tool, this breaks core functionality.

Suggested change
.read_only(true)
.read_only(false)

@kilo-code-bot
Copy link

kilo-code-bot bot commented Mar 9, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Review Notes

The PR changes SQLite connection handling from using a simple URL string to using SqliteConnectOptions, which provides more flexibility for future configuration options.

Changes verified:

Previously reported issue resolved:
The .read_only(true) setting that was present in an earlier version has been removed, allowing full read-write access to SQLite databases as expected for a database management tool.

Files Reviewed (1 file)
  • src-tauri/src/pool_manager.rs - SQLite connection pool refactoring

@debba debba merged commit 87ff041 into debba:main Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants