@@ -142,7 +142,7 @@ class _TransactionContext implements SqliteWriteContext {
142142 Future <sqlite.ResultSet > getAll (String sql,
143143 [List <Object ?> parameters = const []]) async {
144144 if (_closed) {
145- throw AssertionError ( 'Transaction closed' );
145+ throw sqlite. SqliteException ( 0 , 'Transaction closed' , null , sql );
146146 }
147147 try {
148148 var future = _sendPort.post< sqlite.ResultSet > (
@@ -183,8 +183,9 @@ class _TransactionContext implements SqliteWriteContext {
183183 return rows.isEmpty ? null : rows[0 ];
184184 }
185185
186- close () {
186+ Future < void > close () async {
187187 _closed = true ;
188+ await _sendPort.post (_SqliteIsolateClose (ctxId));
188189 }
189190
190191 @override
@@ -234,8 +235,8 @@ void _sqliteConnectionIsolate(_SqliteConnectionParams params) async {
234235 }
235236 txId = null ;
236237 txError = null ;
237- throw AssertionError (
238- 'Transaction must be closed within the read or write lock' );
238+ throw sqlite. SqliteException (
239+ 0 , 'Transaction must be closed within the read or write lock' );
239240 }
240241 } else if (data is _SqliteIsolateStatement ) {
241242 if (data.sql == 'BEGIN' || data.sql == 'BEGIN IMMEDIATE' ) {
@@ -254,7 +255,7 @@ void _sqliteConnectionIsolate(_SqliteConnectionParams params) async {
254255 // Any statement (including COMMIT) after the first error will also error, until the
255256 // transaction is aborted.
256257 throw txError! ;
257- } else if (data.sql == 'COMMIT' ) {
258+ } else if (data.sql == 'COMMIT' || data.sql == 'END TRANSACTION' ) {
258259 txId = null ;
259260 }
260261 try {
0 commit comments