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



517
518
519
# File 'lib/sequel_core/sql.rb', line 517

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)



511
512
513
# File 'lib/sequel_core/sql.rb', line 511

def args
  @args
end

#fObject (readonly)

The SQL function to call



514
515
516
# File 'lib/sequel_core/sql.rb', line 514

def f
  @f
end

Instance Method Details

#==(x) ⇒ Object

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



523
524
525
# File 'lib/sequel_core/sql.rb', line 523

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.



529
530
531
# File 'lib/sequel_core/sql.rb', line 529

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