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
552 553 554 |
# File 'lib/sequel_core/sql.rb', line 552 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)
543 544 545 |
# File 'lib/sequel_core/sql.rb', line 543 def arg1 @arg1 end |
#arg2 ⇒ Object (readonly)
The arguments to pass to the function (may be blank)
543 544 545 |
# File 'lib/sequel_core/sql.rb', line 543 def arg2 @arg2 end |
#f ⇒ Object (readonly)
The SQL function to call
546 547 548 |
# File 'lib/sequel_core/sql.rb', line 546 def f @f end |
#joiner ⇒ Object (readonly)
The literal string to use in place of a comma to join arguments
549 550 551 |
# File 'lib/sequel_core/sql.rb', line 549 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.
558 559 560 |
# File 'lib/sequel_core/sql.rb', line 558 def to_s(ds) ds.irregular_function_sql(self) end |