render method

  1. @override
String render(
  1. RenderContext context
)
override

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 (joins.isEmpty) return '';
  final chunks = <String>[];
  for (final join in joins) {
    if (join is InnerJoin) {
      chunks.add('INNER JOIN');
    } else if (join is LeftJoin) {
      chunks.add('LEFT JOIN');
    } else if (join is RightJoin) {
      chunks.add('RIGHT JOIN');
    } else {
      throw UnsupportedError('$join');
    }
    chunks
      ..add(TableClause(join.table).render(context))
      ..add('ON ${FilterClause(join.on).render(context)}');
  }
  return chunks.join(' ');
}