diff --git a/drift/lib/src/remote/protocol.dart b/drift/lib/src/remote/protocol.dart index 1c455ac28..d6ddb99fd 100644 --- a/drift/lib/src/remote/protocol.dart +++ b/drift/lib/src/remote/protocol.dart @@ -191,7 +191,7 @@ class DriftProtocol { list[0] as int, list.skip(1).toList())); } - final executorId = fullMessage.last as int; + final executorId = fullMessage.last as int?; return ExecuteBatchedStatement( BatchedStatements(sql, args), executorId); case _tag_RunTransactionAction: diff --git a/drift/test/remote_test.dart b/drift/test/remote_test.dart index fba747e54..d9845fc41 100644 --- a/drift/test/remote_test.dart +++ b/drift/test/remote_test.dart @@ -149,6 +149,15 @@ void main() { (e) => e.remoteCause, 'remoteCause', 'UnimplementedError: error!')), ); + final statements = + BatchedStatements(['SELECT 1'], [ArgumentsForBatchedStatement(0, [])]); + when(executor.runBatched(any)).thenAnswer((i) => Future.value()); + // Not using db.batch because that starts a transaction, we want to test + // this working with the default executor. + // Regression test for: https://github.com/simolus3/drift/pull/2707 + await db.executor.runBatched(statements); + verify(executor.runBatched(statements)); + await db.close(); });