The StringAgg class represents an aggregate string concatentation.
The string expression for each row that will concatenated to the output.
The expression that the aggregation is ordered by.
The separator between each string expression.
Set the expression and separator
# File lib/sequel/extensions/string_agg.rb, line 147 def initialize(expr, separator=nil) @expr = expr @separator = separator yield self if block_given? freeze end
Return a modified StringAgg that uses distinct expressions
# File lib/sequel/extensions/string_agg.rb, line 160 def distinct self.class.new(@expr, @separator) do |sa| sa.instance_variable_set(:@order_expr, @order_expr) if @order_expr sa.instance_variable_set(:@distinct, true) end end
Whether the current expression uses distinct expressions
# File lib/sequel/extensions/string_agg.rb, line 155 def is_distinct? @distinct == true end
Return a modified StringAgg with the given order
# File lib/sequel/extensions/string_agg.rb, line 168 def order(*o) self.class.new(@expr, @separator) do |sa| sa.instance_variable_set(:@distinct, @distinct) if @distinct sa.instance_variable_set(:@order_expr, o.empty? ? nil : o.freeze) end end