class Sequel::SQL::StringAgg

  1. lib/sequel/extensions/string_agg.rb
Superclass: GenericExpression

The StringAgg class represents an aggregate string concatentation.

Methods

Public Class

  1. new

Public Instance

  1. distinct
  2. expr
  3. is_distinct?
  4. order
  5. order_expr
  6. separator

Included modules

  1. StringMethods
  2. StringConcatenationMethods
  3. InequalityMethods
  4. AliasMethods
  5. CastMethods
  6. OrderMethods
  7. PatternMatchMethods
  8. SubscriptMethods

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

new (expr, separator=nil)

Set the expression and separator

[show source]
# File lib/sequel/extensions/string_agg.rb, line 146
def initialize(expr, separator=nil)
  @expr = expr
  @separator = separator
  yield self if block_given?
  freeze
end

Public Instance methods

distinct ()

Return a modified StringAgg that uses distinct expressions

[show source]
# File lib/sequel/extensions/string_agg.rb, line 159
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
is_distinct? ()

Whether the current expression uses distinct expressions

[show source]
# File lib/sequel/extensions/string_agg.rb, line 154
def is_distinct?
  @distinct == true
end
order (*o)

Return a modified StringAgg with the given order

[show source]
# File lib/sequel/extensions/string_agg.rb, line 167
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