run method

Future<int> run(
  1. MySQLConnection connection
)

Implementation

Future<int> run(MySQLConnection connection) async {
  //return connection.execute(compile());
  int affectedRows = 0;
  await connection
      .transactional((ctx) async {
        var sql = compile();
        //print('Query: $sql');
        var result = await ctx.execute(sql).catchError((e) {
          _log.severe('Failed to run query: [ $sql ]', e);
          throw Exception(e);
        });
        affectedRows = result.affectedRows.toInt();
      })
      .catchError((e) {
        _log.severe('Failed to run query in a transaction', e);
      });

  return affectedRows;
}