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
614 615 616 |
# File 'lib/sequel_core/sql.rb', line 614 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)
605 606 607 |
# File 'lib/sequel_core/sql.rb', line 605 def arg1 @arg1 end |
#arg2 ⇒ Object (readonly)
The arguments to pass to the function (may be blank)
605 606 607 |
# File 'lib/sequel_core/sql.rb', line 605 def arg2 @arg2 end |
#f ⇒ Object (readonly)
The SQL function to call
608 609 610 |
# File 'lib/sequel_core/sql.rb', line 608 def f @f end |
#joiner ⇒ Object (readonly)
The literal string to use in place of a comma to join arguments
611 612 613 |
# File 'lib/sequel_core/sql.rb', line 611 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.
620 621 622 |
# File 'lib/sequel_core/sql.rb', line 620 def to_s(ds) ds.irregular_function_sql(self) end |