render method
Renders this clause to SQL text, recording any bind values on context.
context is the entire context a clause is given: use
RenderContext.escapeName for identifiers and RenderContext.param
for values.
Return an empty string to render nothing, which is how an optional clause
(such as a WHERE with no filter) drops itself from the statement.
Implementation
@override
String render(RenderContext context) {
if (terms.isEmpty) return '';
final rendered = terms.map((term) {
final sql = switch (term.term) {
final Expression<dynamic> expr => expr.build(),
final Column<dynamic, Object?> column => SQL([column]),
_ => throw UnsupportedError(
'Unsupported ORDER BY term: ${term.term.runtimeType}',
),
};
final direction = term.descending ? 'DESC' : 'ASC';
final clause = ExpressionClause(sql, singleTable: singleTable);
return '${clause.render(context)} $direction';
});
return 'ORDER BY ${rendered.join(', ')}';
}