query<T> method
Executes an explicitly row-returning D1 statement.
D1's raw result does not expose enough shape metadata to distinguish an empty query from a write. Requiring SqlStatementKind.rowReturning prevents an unknown write from being sent through this terminal.
Implementation
@override
Future<List<T>> query<T>(
BoundSql statement,
T Function(SqlRow row) decode,
) async {
_ensureOpen();
_requireTopLevelQuery(statement);
final JSAny? raw;
try {
raw = await _prepare(
statement,
).raw(_D1RawOptions(columnNames: true)).toDart;
} on Object catch (error) {
_throwD1(error);
}
final rows = _readRows(raw);
return <T>[for (final row in rows) decode(row)];
}