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) {
final buffer = StringBuffer();
for (var i = 0; i < sql.chunks.length; i++) {
final chunk = sql.chunks[i];
if (chunk case [final Subquery<dynamic> only]) {
buffer.write(_chunk(context, only));
} else if (chunk case final List<dynamic> list) {
buffer.write('(');
for (var j = 0; j < list.length; j++) {
if (j > 0) buffer.write(', ');
buffer.write(_chunk(context, list[j]));
}
buffer.write(')');
} else {
buffer.write(_chunk(context, chunk));
}
if (i != sql.chunks.length - 1 &&
!_endsWithOpenParen(chunk) &&
!_startsWithCloseParen(sql.chunks[i + 1]) &&
!_isComma(sql.chunks[i + 1])) {
buffer.write(' ');
}
}
return buffer.toString();
}