Method: Babik::QuerySet::AbstractAggregationFunction#sql

Defined in:
lib/babik/queryset/components/aggregation.rb

#sqlString

Return aggregation function SQL

Returns:

  • (String)

    Aggregation function SQL



63
64
65
66
67
# File 'lib/babik/queryset/components/aggregation.rb', line 63

def sql
  selected_field_path = "#{@selection.target_alias}.#{@selection.selected_field}"
  operation = self.sql_operation.sub('?field', selected_field_path)
  "#{operation} AS #{@field_name}"
end