Class: Sequel::SQL::StringAgg
- Inherits:
-
GenericExpression
- Object
- Expression
- GenericExpression
- Sequel::SQL::StringAgg
- Includes:
- AliasMethods, CastMethods, InequalityMethods, OrderMethods, PatternMatchMethods, StringConcatenationMethods, StringMethods, SubscriptMethods
- Defined in:
- lib/sequel/extensions/string_agg.rb
Overview
The StringAgg class represents an aggregate string concatentation.
Defined Under Namespace
Modules: DatasetMethods
Instance Attribute Summary collapse
-
#expr ⇒ Object
readonly
The string expression for each row that will concatenated to the output.
-
#order_expr ⇒ Object
readonly
The expression that the aggregation is ordered by.
-
#separator ⇒ Object
readonly
The separator between each string expression.
Instance Method Summary collapse
-
#distinct ⇒ Object
Return a modified StringAgg that uses distinct expressions.
-
#initialize(expr, separator = nil) ⇒ StringAgg
constructor
Set the expression and separator.
-
#is_distinct? ⇒ Boolean
Whether the current expression uses distinct expressions.
-
#order(*o) ⇒ Object
Return a modified StringAgg with the given order.
Methods included from SubscriptMethods
Methods included from PatternMatchMethods
Methods included from OrderMethods
Methods included from CastMethods
#cast, #cast_numeric, #cast_string
Methods included from AliasMethods
Methods included from StringConcatenationMethods
Methods included from StringMethods
Methods included from Postgres::HStoreOpMethods
Methods included from Postgres::RangeOpMethods
Methods included from Postgres::ArrayOpMethods
Methods included from Postgres::JSONOpMethods
Methods included from Postgres::InetOpMethods
Methods included from Postgres::PGRowOp::ExpressionMethods
Methods included from NumericMethods
Methods included from ComplexExpressionMethods
#extract, #sql_boolean, #sql_number, #sql_string
Methods included from BooleanMethods
Methods inherited from Expression
#==, attr_reader, #eql?, #hash, inherited, #inspect, #lit, #sql_literal
Constructor Details
#initialize(expr, separator = nil) ⇒ StringAgg
Set the expression and separator
148 149 150 151 |
# File 'lib/sequel/extensions/string_agg.rb', line 148 def initialize(expr, separator=nil) @expr = expr @separator = separator end |
Instance Attribute Details
#expr ⇒ Object (readonly)
The string expression for each row that will concatenated to the output.
139 140 141 |
# File 'lib/sequel/extensions/string_agg.rb', line 139 def expr @expr end |
#order_expr ⇒ Object (readonly)
The expression that the aggregation is ordered by.
145 146 147 |
# File 'lib/sequel/extensions/string_agg.rb', line 145 def order_expr @order_expr end |
#separator ⇒ Object (readonly)
The separator between each string expression.
142 143 144 |
# File 'lib/sequel/extensions/string_agg.rb', line 142 def separator @separator end |
Instance Method Details
#distinct ⇒ Object
Return a modified StringAgg that uses distinct expressions
159 160 161 162 163 |
# File 'lib/sequel/extensions/string_agg.rb', line 159 def distinct sa = dup sa.instance_variable_set(:@distinct, true) sa end |
#is_distinct? ⇒ Boolean
Whether the current expression uses distinct expressions
154 155 156 |
# File 'lib/sequel/extensions/string_agg.rb', line 154 def is_distinct? @distinct == true end |
#order(*o) ⇒ Object
Return a modified StringAgg with the given order
166 167 168 169 170 |
# File 'lib/sequel/extensions/string_agg.rb', line 166 def order(*o) sa = dup sa.instance_variable_set(:@order_expr, o.empty? ? nil : o) sa end |