class Sequel::SQL::StringAgg
The StringAgg
class represents an aggregate string concatentation.
Attributes
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.
Public Class Methods
Source
# File lib/sequel/extensions/string_agg.rb 161 def initialize(expr, separator=nil) 162 @expr = expr 163 @separator = separator 164 yield self if defined?(yield) 165 freeze 166 end
Set the expression and separator
Public Instance Methods
Source
# File lib/sequel/extensions/string_agg.rb 174 def distinct 175 self.class.new(@expr, @separator) do |sa| 176 sa.instance_variable_set(:@order_expr, @order_expr) 177 sa.instance_variable_set(:@distinct, true) 178 end 179 end
Return a modified StringAgg
that uses distinct expressions
Source
# File lib/sequel/extensions/string_agg.rb 169 def is_distinct? 170 @distinct == true 171 end
Whether the current expression uses distinct expressions
Source
# File lib/sequel/extensions/string_agg.rb 182 def order(*o) 183 self.class.new(@expr, @separator) do |sa| 184 sa.instance_variable_set(:@order_expr, o.empty? ? nil : o.freeze) 185 sa.instance_variable_set(:@distinct, @distinct) 186 end 187 end
Return a modified StringAgg
with the given order