Class: Sequel::SQL::Function
- Inherits:
-
GenericExpression
- Object
- Expression
- GenericExpression
- Sequel::SQL::Function
- Defined in:
- lib/sequel/sql.rb,
lib/sequel/extensions/eval_inspect.rb
Overview
Represents an SQL function call.
Direct Known Subclasses
Constant Summary collapse
- WILDCARD =
LiteralString.new('*').freeze
- DISTINCT =
["DISTINCT ".freeze].freeze
- COMMA_ARRAY =
[LiteralString.new(', ').freeze].freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
The array of arguments to pass to the function (may be blank).
-
#f ⇒ Object
readonly
The SQL function to call.
Instance Method Summary collapse
-
#*(ce = (arg=false;nil)) ⇒ Object
If no arguments are given, return a new function with the wildcard prepended to the arguments.
-
#distinct ⇒ Object
Return a new function with DISTINCT before the method arguments.
-
#initialize(f, *args) ⇒ Function
constructor
Set the functions and args to the given arguments.
-
#over(opts = OPTS) ⇒ Object
Create a WindowFunction using the receiver and the appropriate options for the window.
Methods included from Postgres::HStoreOpMethods
Methods included from Postgres::RangeOpMethods
Methods included from Postgres::ArrayOpMethods
Methods included from Postgres::JSONOpMethods
Methods included from Postgres::PGRowOp::ExpressionMethods
Methods included from SubscriptMethods
Methods included from StringMethods
Methods included from OrderMethods
Methods included from NumericMethods
Methods included from ComplexExpressionMethods
#extract, #sql_boolean, #sql_number, #sql_string
Methods included from CastMethods
#cast, #cast_numeric, #cast_string
Methods included from BooleanMethods
Methods included from AliasMethods
Methods inherited from Expression
#==, attr_reader, #eql?, #hash, inherited, #inspect, #lit, #sql_literal
Constructor Details
#initialize(f, *args) ⇒ Function
Set the functions and args to the given arguments
1225 1226 1227 |
# File 'lib/sequel/sql.rb', line 1225 def initialize(f, *args) @f, @args = f, args end |
Instance Attribute Details
#args ⇒ Object (readonly)
The array of arguments to pass to the function (may be blank)
1222 1223 1224 |
# File 'lib/sequel/sql.rb', line 1222 def args @args end |
#f ⇒ Object (readonly)
The SQL function to call
1219 1220 1221 |
# File 'lib/sequel/sql.rb', line 1219 def f @f end |
Instance Method Details
#*(ce = (arg=false;nil)) ⇒ Object
1233 1234 1235 1236 1237 1238 1239 |
# File 'lib/sequel/sql.rb', line 1233 def *(ce=(arg=false;nil)) if arg == false Function.new(f, WILDCARD, *args) else super(ce) end end |
#distinct ⇒ Object
Return a new function with DISTINCT before the method arguments.
1242 1243 1244 |
# File 'lib/sequel/sql.rb', line 1242 def distinct Function.new(f, PlaceholderLiteralString.new(DISTINCT + COMMA_ARRAY * (args.length-1), args)) end |
#over(opts = OPTS) ⇒ Object
Create a WindowFunction using the receiver and the appropriate options for the window.
1247 1248 1249 |
# File 'lib/sequel/sql.rb', line 1247 def over(opts=OPTS) WindowFunction.new(self, Window.new(opts)) end |