Class: Repor::Aggregators::ArrayAggregator

Inherits:
BaseAggregator show all
Defined in:
lib/repor/aggregators/array_aggregator.rb

Instance Attribute Summary

Attributes inherited from BaseAggregator

#name, #opts, #report

Instance Method Summary collapse

Methods inherited from BaseAggregator

#aggregate, #initialize

Constructor Details

This class inherits a constructor from Repor::Aggregators::BaseAggregator

Instance Method Details

#aggregation(groups) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/repor/aggregators/array_aggregator.rb', line 4

def aggregation(groups)
  unless Repor.database_type == :postgres
    fail InvalidParamsError, "array agg is only supported in Postgres"
  end

  groups.select("ARRAY_AGG(#{expression}) AS #{sql_value_name}")
end