Class: Sequel::SQL::Function

Inherits:
Expression show all
Includes:
ComplexExpressionMethods
Defined in:
lib/sequel_core/sql.rb

Overview

Represents an SQL function call.

Constant Summary

Constants included from ColumnMethods

ColumnMethods::AS, ColumnMethods::ASC, ColumnMethods::DESC

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComplexExpressionMethods

#sql_boolean, #sql_number, #sql_string

Methods included from StringMethods

#ilike, #like

Methods included from BooleanMethods

#~

Methods inherited from Expression

#lit

Methods included from ColumnMethods

#as, #asc, #cast_as, #desc

Constructor Details

#initialize(f, *args) ⇒ Function

Set the attributes to the given arguments



431
432
433
# File 'lib/sequel_core/sql.rb', line 431

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)



425
426
427
# File 'lib/sequel_core/sql.rb', line 425

def args
  @args
end

#fObject (readonly)

The SQL function to call



428
429
430
# File 'lib/sequel_core/sql.rb', line 428

def f
  @f
end

Instance Method Details

#==(x) ⇒ Object

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



437
438
439
# File 'lib/sequel_core/sql.rb', line 437

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.



443
444
445
# File 'lib/sequel_core/sql.rb', line 443

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