@@ -222,15 +222,21 @@ void main() {
222222 await createTables (db);
223223
224224 var tp = db.writeTransaction ((tx) async {
225- tx.execute (
225+ await tx.execute (
226226 'INSERT OR ROLLBACK INTO test_data(id, description) VALUES(?, ?)' ,
227227 [1 , 'test1' ]);
228- tx.execute (
228+ await tx.execute (
229229 'INSERT OR ROLLBACK INTO test_data(id, description) VALUES(?, ?)' ,
230230 [2 , 'test2' ]);
231- ignore (tx.execute (
232- 'INSERT OR ROLLBACK INTO test_data(id, description) VALUES(?, ?)' ,
233- [2 , 'test3' ])); // Errors
231+ expect (await tx.isOpen (), equals (true ));
232+ try {
233+ await tx.execute (
234+ 'INSERT OR ROLLBACK INTO test_data(id, description) VALUES(?, ?)' ,
235+ [2 , 'test3' ]);
236+ } catch (e) {
237+ // Ignore
238+ }
239+ expect (await tx.isOpen (), equals (false ));
234240
235241 // Will not be executed because of the above rollback
236242 ignore (tx.execute (
@@ -337,7 +343,9 @@ void main() {
337343 test ('should allow resuming transaction after errors' , () async {
338344 final db = await setupDatabase (path: path);
339345 await createTables (db);
346+ SqliteWriteContext ? savedTx;
340347 await db.writeTransaction ((tx) async {
348+ savedTx = tx;
341349 var caught = false ;
342350 try {
343351 // This error does not rollback the transaction
@@ -348,11 +356,14 @@ void main() {
348356 }
349357 expect (caught, equals (true ));
350358
359+ expect (await tx.isOpen (), equals (true ));
360+
351361 final rs = await tx.execute (
352362 'INSERT INTO test_data(description) VALUES(?) RETURNING description' ,
353363 ['Test Data' ]);
354364 expect (rs.rows[0 ], equals (['Test Data' ]));
355365 });
366+ expect (await savedTx! .isOpen (), equals (false ));
356367 });
357368 });
358369}
0 commit comments