Class: Sequel::SQL::IrregularFunction
- Inherits:
-
Function
- Object
- Expression
- GenericExpression
- Function
- Sequel::SQL::IrregularFunction
- 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
-
#arg1 ⇒ Object
readonly
The arguments to pass to the function (may be blank).
-
#arg2 ⇒ Object
readonly
The arguments to pass to the function (may be blank).
-
#f ⇒ Object
readonly
The SQL function to call.
-
#joiner ⇒ Object
readonly
The literal string to use in place of a comma to join arguments.
Attributes inherited from Function
Instance Method Summary collapse
-
#initialize(f, arg1, joiner, arg2) ⇒ IrregularFunction
constructor
Set the attributes to the given arguments.
-
#to_s(ds) ⇒ Object
Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.
Methods inherited from Function
Methods included from ComplexExpressionMethods
#extract, #sql_boolean, #sql_number, #sql_string
Methods included from StringMethods
Methods included from BooleanMethods
Methods included from OrderMethods
Methods included from CastMethods
#cast, #cast_numeric, #cast_string
Methods included from AliasMethods
Methods inherited from Expression
Constructor Details
#initialize(f, arg1, joiner, arg2) ⇒ IrregularFunction
Set the attributes to the given arguments
589 590 591 |
# File 'lib/sequel_core/sql.rb', line 589 def initialize(f, arg1, joiner, arg2) @f, @arg1, @joiner, @arg2 = f, arg1, joiner, arg2 end |
Instance Attribute Details
#arg1 ⇒ Object (readonly)
The arguments to pass to the function (may be blank)
580 581 582 |
# File 'lib/sequel_core/sql.rb', line 580 def arg1 @arg1 end |
#arg2 ⇒ Object (readonly)
The arguments to pass to the function (may be blank)
580 581 582 |
# File 'lib/sequel_core/sql.rb', line 580 def arg2 @arg2 end |
#f ⇒ Object (readonly)
The SQL function to call
583 584 585 |
# File 'lib/sequel_core/sql.rb', line 583 def f @f end |
#joiner ⇒ Object (readonly)
The literal string to use in place of a comma to join arguments
586 587 588 |
# File 'lib/sequel_core/sql.rb', line 586 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.
595 596 597 |
# File 'lib/sequel_core/sql.rb', line 595 def to_s(ds) ds.irregular_function_sql(self) end |