apollo-ios icon indicating copy to clipboard operation
apollo-ios copied to clipboard

SQLite: Ability to change journal mode

Open pixelmatrix opened this issue 8 months ago • 3 comments

Use case

I've been investigating a regular background crash in our app. After some research, it appears to be due to keeping the SQLite database file located in the App Group's container. It looks like other people have fixed these crashes by using the database in WAL mode. This is possibly by executing a PRAGMA statement:

try db.execute("PRAGMA journal_mode = WAL;")

Describe the solution you'd like

Would you be open to exposing this as an option in some form?

A few API ideas:

  1. setJournalMode(_ mode: JournalMode) throws on SQLiteDatabase protocol
  2. execute(_ sql: String) throws on SQLiteDatabase, which would allow direct access to execute any PRAGMA command
  3. Add useWAL as an optional init parameter of SQLiteNormalizedCache

Alternatively, I could implement my own SQLiteDatabase, but that is currently not possible because DatabaseRow does not have a public initializer.

pixelmatrix avatar Jun 26 '24 23:06 pixelmatrix