diff --git a/lib/core/database/sqlite_connection.dart b/lib/core/database/sqlite_connection.dart index c699fa2..153bdf9 100644 --- a/lib/core/database/sqlite_connection.dart +++ b/lib/core/database/sqlite_connection.dart @@ -45,6 +45,7 @@ class SqliteConnection { options: OpenDatabaseOptions( readOnly: readOnly, onOpen: (db) async { + await db.execute('PRAGMA busy_timeout = 5000'); if (!readOnly) { await db.execute('PRAGMA foreign_keys = ON'); } diff --git a/test/core/database/sqlite_connection_test.dart b/test/core/database/sqlite_connection_test.dart index cd2612f..d00cfbe 100644 --- a/test/core/database/sqlite_connection_test.dart +++ b/test/core/database/sqlite_connection_test.dart @@ -69,6 +69,13 @@ void main() { expect(conn.isConnected, false); }); + test('configures PRAGMA busy_timeout to 5000 on connection open', () async { + await conn.connect(); + final res = await conn.execute('PRAGMA busy_timeout'); + expect(res, isNotEmpty); + expect(res.first['timeout'], 5000); + }); + test('testConnection connects, queries and cleans up', () async { final ok = await conn.testConnection(); expect(ok, true);