flushPending method

Future<void> flushPending()

Implementation

Future<void> flushPending() async {
  _checkDriver();
  while (_pendingDML.isNotEmpty) {
    final p = _pendingDML.first;
    final res = await driver!.executeRawSql(p.sql, p.args);
    if (!res.success) {
      // @@@ Failed entries stay at the head of the queue (the caller can check pendingCount to decide whether to retry or
      // @@@ discard via rollback); the error is thrown back to the caller
      throw ESQLDatabaseError.createFmt(
          res.errorMessage ?? 'execute failed', [], this, 0, "");
    }
    _lastRowsAffected = res.affectedRows;
    _pendingDML.removeAt(0);
  }
}