one method

Future<R> one(
  1. SqlExecutor executor
)

Returns the only row produced by this operation.

Throws StateError when the operation returns no rows or multiple rows. Projection reads built by SqlQueries.select fetch at most two rows for this check. An explicit query limit of zero, one, or two is preserved.

Implementation

Future<R> one(SqlExecutor executor) async {
  final rows = await _cardinalityRows(executor);
  if (rows.isEmpty) {
    throw StateError(
      'Expected exactly one SQL row, but no rows were returned.',
    );
  }
  if (rows.length > 1) {
    throw StateError(
      'Expected exactly one SQL row, but multiple rows were returned.',
    );
  }
  return _decode(rows.single);
}