query<T> method
Executes a row-returning statement and decodes every row in order.
Use this method for SELECT and dialect-supported statements containing
RETURNING. The driver invokes decode exactly once per returned row.
A non-null BoundSql.dialect must match the driver and is rejected before
that statement reaches the database when it does not.
The terminal is part of the caller contract: some database protocols only
reveal the result shape after execution, so choosing the wrong terminal
can still apply a statement's side effects before it is rejected.
Implementation
@override
Future<List<T>> query<T>(BoundSql statement, T Function(SqlRow row) decode) {
return _schedule(() async {
_requireTopLevelQuery(statement);
final response = await _runConnection(
(lease) => _send(lease.connection, statement, operation: 'query'),
);
return _decodeQuery(response, decode);
});
}