Skip to content

Commit 01698aa

Browse files
committed
Fix the example.
1 parent 723e2c4 commit 01698aa

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ void main() async {
6565
// 1. Atomic persistence (all updates are either applied or rolled back).
6666
// 2. Improved throughput.
6767
await db.writeTransaction((tx) async {
68-
await db.execute('INSERT INTO test_data(data) values(?)', ['Test3']);
69-
await db.execute('INSERT INTO test_data(data) values(?)', ['Test4']);
68+
await tx.execute('INSERT INTO test_data(data) values(?)', ['Test3']);
69+
await tx.execute('INSERT INTO test_data(data) values(?)', ['Test4']);
7070
});
7171
7272
await db.close();

example/basic_example.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void main() async {
2929
// 1. Atomic persistence (all updates are either applied or rolled back).
3030
// 2. Improved throughput.
3131
await db.writeTransaction((tx) async {
32-
await db.execute('INSERT INTO test_data(data) values(?)', ['Test3']);
33-
await db.execute('INSERT INTO test_data(data) values(?)', ['Test4']);
32+
await tx.execute('INSERT INTO test_data(data) values(?)', ['Test3']);
33+
await tx.execute('INSERT INTO test_data(data) values(?)', ['Test4']);
3434
});
3535

3636
// Close database to release resources

test/basic_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ void main() {
175175
// Note: In highly concurrent cases, it could exhaust the connection pool and cause a deadlock.
176176

177177
await db.writeTransaction((tx) async {
178+
// Use the parent zone to avoid the "recursive lock" error.
178179
await zone.fork().run(() async {
179180
await db.getAll('SELECT * FROM test_data');
180181
});
@@ -192,7 +193,7 @@ void main() {
192193
});
193194
});
194195

195-
// This would deadlock, since it shares a global write lock.
196+
// Note: This would deadlock, since it shares a global write lock.
196197
// await db.writeTransaction((tx) async {
197198
// await zone.fork().run(() async {
198199
// await db.execute('SELECT * FROM test_data');

0 commit comments

Comments
 (0)