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



593
594
595
# File 'lib/sequel_core/sql.rb', line 593

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)



584
585
586
# File 'lib/sequel_core/sql.rb', line 584

def arg1
  @arg1
end

#arg2Object (readonly)

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



584
585
586
# File 'lib/sequel_core/sql.rb', line 584

def arg2
  @arg2
end

#fObject (readonly)

The SQL function to call



587
588
589
# File 'lib/sequel_core/sql.rb', line 587

def f
  @f
end

#joinerObject (readonly)

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



590
591
592
# File 'lib/sequel_core/sql.rb', line 590

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.



599
600
601
# File 'lib/sequel_core/sql.rb', line 599

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