executeTransactionOperation<R> method

FutureOr<R> executeTransactionOperation<R>(
  1. TransactionOperation op,
  2. SQLWrapper sql,
  3. FutureOr<R> f(
    1. C connection
    )
)

Implementation

FutureOr<R> executeTransactionOperation<R>(TransactionOperation op,
    SQLWrapper sql, FutureOr<R> Function(C connection) f) {
  var transaction = op.transaction;

  if (isTransactionWithSingleOperation(op, sql)) {
    return executeWithPool(f,
        onError: (e, s) => transaction.notifyExecutionError(
              e,
              s,
              errorResolver: resolveError,
              operation: op,
              debugInfo: () => sql.mainSQL.toString(),
            ));
  }

  if (transaction.isOpen) {
    return transaction.addExecution<R, C>(
      f,
      errorResolver: resolveError,
      operation: op,
      debugInfo: () => sql.mainSQL.toString(),
    );
  }

  if (!transaction.isOpening) {
    transaction.open(
      () => openTransaction(transaction),
      callCloseTransactionRequired
          ? () => closeTransaction(transaction, transaction.context as C?)
          : null,
    );
  }

  return transaction.onOpen<R>(() {
    return transaction.addExecution<R, C>(
      f,
      errorResolver: resolveError,
      operation: op,
      debugInfo: () => sql.mainSQL.toString(),
    );
  });
}