Method: Array#sql_string_join
- Defined in:
- lib/sequel/core_sql.rb
#sql_string_join(joiner = nil) ⇒ Object
Return a Sequel::SQL::BooleanExpression representing an SQL string made up of the concatenation of this array’s elements. If an argument is passed it is used in between each element of the array in the SQL concatenation.
[:a].sql_string_join # SQL: a
[:a, :b].sql_string_join # SQL: a || b
[:a, 'b'].sql_string_join # SQL: a || 'b'
['a', :b].sql_string_join(' ') # SQL: 'a' || ' ' || b
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/sequel/core_sql.rb', line 92 def sql_string_join(joiner=nil) if joiner args = zip([joiner]*length).flatten args.pop else args = self end args = args.collect{|a| [Symbol, ::Sequel::SQL::Expression, ::Sequel::LiteralString, TrueClass, FalseClass, NilClass].any?{|c| a.is_a?(c)} ? a : a.to_s} ::Sequel::SQL::StringExpression.new(:'||', *args) end |