single method
Returns exactly one selected row or throws QUERY.CARDINALITY.
Fetches at most two root rows to detect an ambiguous result.
Implementation
Future<R> single({
ExecutionOptions options = const ExecutionOptions(),
}) async {
final rows = await take(
queryState.limit == null || queryState.limit! > 2 ? 2 : queryState.limit!,
).get(options: options);
if (rows.length != 1) {
throw OrmException(
'QUERY.CARDINALITY',
'Expected one row, received ${rows.length}.',
);
}
return rows.single;
}