Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/core/database/sqlite_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
7 changes: 7 additions & 0 deletions test/core/database/sqlite_connection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading