Class: Sequel::SQL::IrregularFunction

Inherits:
Function show all
Defined in:
lib/sequel_core/sql.rb

Overview

IrregularFunction is used for the SQL EXTRACT and CAST functions, which don’t use regular function calling syntax. The IrregularFunction replaces the commas the regular function uses with a custom join string.

This shouldn’t be used directly, see CastMethods#cast and ComplexExpressionMethods#extract.

Instance Attribute Summary collapse

Attributes inherited from Function

#args

Instance Method Summary collapse

Methods inherited from Function

#==

Methods included from ComplexExpressionMethods

#extract, #sql_boolean, #sql_number, #sql_string

Methods included from StringMethods

#ilike, #like

Methods included from BooleanMethods

#~

Methods included from OrderMethods

#asc, #desc

Methods included from CastMethods

#cast, #cast_numeric, #cast_string

Methods included from AliasMethods

#as

Methods inherited from Expression

#lit

Constructor Details

#initialize(f, arg1, joiner, arg2) ⇒ IrregularFunction

Set the attributes to the given arguments



552
553
554
# File 'lib/sequel_core/sql.rb', line 552

def initialize(f, arg1, joiner, arg2)
  @f, @arg1, @joiner, @arg2 = f, arg1, joiner, arg2
end

Instance Attribute Details

#arg1Object (readonly)

The arguments to pass to the function (may be blank)



543
544
545
# File 'lib/sequel_core/sql.rb', line 543

def arg1
  @arg1
end

#arg2Object (readonly)

The arguments to pass to the function (may be blank)



543
544
545
# File 'lib/sequel_core/sql.rb', line 543

def arg2
  @arg2
end

#fObject (readonly)

The SQL function to call



546
547
548
# File 'lib/sequel_core/sql.rb', line 546

def f
  @f
end

#joinerObject (readonly)

The literal string to use in place of a comma to join arguments



549
550
551
# File 'lib/sequel_core/sql.rb', line 549

def joiner
  @joiner
end

Instance Method Details

#to_s(ds) ⇒ Object

Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.



558
559
560
# File 'lib/sequel_core/sql.rb', line 558

def to_s(ds)
  ds.irregular_function_sql(self)
end