addAggregateFunctionExpression method

void addAggregateFunctionExpression(
  1. AggregateFunctionExpression<Object> expr
)

Implementation

void addAggregateFunctionExpression(AggregateFunctionExpression expr) {
  writeExpression(expr, () {
    addFunctionName(expr, expr.functionName);
    statement.buffer.write('(');
    _expressionPrecedence = null; // We're inside of parentheses
    if (expr.distinct) {
      statement.buffer.write('DISTINCT ');
    }
    addCommaSeparated(expr.arguments);
    if (expr.orderBy case final orderBy?) {
      statement.space();
      orderBy.compileWith(this);
    }
    statement.buffer.write(')');

    if (expr.filter case final filter?) {
      statement.buffer.write(' FILTER (WHERE ');
      filter.compileWith(this);
      statement.buffer.write(')');
    }
  });
}