Class Sequel::SQL::StringAgg
In: lib/sequel/extensions/string_agg.rb
Parent: GenericExpression

The StringAgg class represents an aggregate string concatentation.

Methods

distinct   is_distinct?   new   order  

Included Modules

StringMethods StringConcatenationMethods InequalityMethods AliasMethods CastMethods OrderMethods PatternMatchMethods SubscriptMethods

Classes and Modules

Module Sequel::SQL::StringAgg::DatasetMethods

Attributes

expr  [R]  The string expression for each row that will concatenated to the output.
order_expr  [R]  The expression that the aggregation is ordered by.
separator  [R]  The separator between each string expression.

Public Class methods

Set the expression and separator

[Source]

     # File lib/sequel/extensions/string_agg.rb, line 147
147:       def initialize(expr, separator=nil)
148:         @expr = expr
149:         @separator = separator
150:         yield self if block_given?
151:         freeze
152:       end

Public Instance methods

Return a modified StringAgg that uses distinct expressions

[Source]

     # File lib/sequel/extensions/string_agg.rb, line 160
160:       def distinct
161:         self.class.new(@expr, @separator) do |sa|
162:           sa.instance_variable_set(:@order_expr, @order_expr) if @order_expr
163:           sa.instance_variable_set(:@distinct, true)
164:         end
165:       end

Whether the current expression uses distinct expressions

[Source]

     # File lib/sequel/extensions/string_agg.rb, line 155
155:       def is_distinct?
156:         @distinct == true
157:       end

Return a modified StringAgg with the given order

[Source]

     # File lib/sequel/extensions/string_agg.rb, line 168
168:       def order(*o)
169:         self.class.new(@expr, @separator) do |sa|
170:           sa.instance_variable_set(:@distinct, @distinct) if @distinct
171:           sa.instance_variable_set(:@order_expr, o.empty? ? nil : o.freeze)
172:         end
173:       end

[Validate]