apollo-ios
apollo-ios copied to clipboard
SQLite: Ability to change journal mode
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:
-
setJournalMode(_ mode: JournalMode) throws
onSQLiteDatabase
protocol -
execute(_ sql: String) throws
onSQLiteDatabase
, which would allow direct access to execute any PRAGMA command - Add
useWAL
as an optional init parameter ofSQLiteNormalizedCache
Alternatively, I could implement my own SQLiteDatabase
, but that is currently not possible because DatabaseRow
does not have a public initializer.