Class: Sequel::SQL::Function

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

Overview

Represents an SQL function call.

Direct Known Subclasses

IrregularFunction

Instance Attribute Summary collapse

Instance Method Summary collapse

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, *args) ⇒ Function

Set the attributes to the given arguments



537
538
539
# File 'lib/sequel_core/sql.rb', line 537

def initialize(f, *args)
  @f, @args = f, args
end

Instance Attribute Details

#argsObject (readonly)

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



531
532
533
# File 'lib/sequel_core/sql.rb', line 531

def args
  @args
end

#fObject (readonly)

The SQL function to call



534
535
536
# File 'lib/sequel_core/sql.rb', line 534

def f
  @f
end

Instance Method Details

#==(x) ⇒ Object

Functions are considered equivalent if they have the same class, function, and arguments.



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

def ==(x)
   x.class == self.class && @f == x.f && @args == x.args
end

#to_s(ds) ⇒ Object

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



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

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