Class: Sequel::SQL::Subscript
- Inherits:
-
GenericExpression
- Object
- Expression
- GenericExpression
- Sequel::SQL::Subscript
- Defined in:
- lib/sequel/sql.rb
Overview
Represents an SQL array access, with multiple possible arguments.
Instance Attribute Summary collapse
-
#expression ⇒ Object
(also: #f)
readonly
The SQL array column.
-
#sub ⇒ Object
readonly
The array of subscripts to use (should be an array of numbers).
Instance Method Summary collapse
-
#[](sub) ⇒ Object
Create a new
Subscriptby accessing a subarray of a multidimensional array. -
#initialize(expression, sub) ⇒ Subscript
constructor
Set the array column and subscripts to the given arguments.
-
#|(sub) ⇒ Object
Create a new
Subscriptappending the given subscript(s) to the current array of subscripts.
Methods included from IsDistinctFrom::Methods
Methods included from Sequel::SQLite::JSONOpMethods
#sqlite_json_op, #sqlite_jsonb_op
Methods included from Postgres::HStoreOpMethods
Methods included from Postgres::RangeOpMethods
Methods included from Postgres::ArrayOpMethods
Methods included from Postgres::JSONOpMethods
Methods included from Postgres::InetOpMethods
Methods included from Postgres::PGRowOp::ExpressionMethods
Methods included from SubscriptMethods
Methods included from StringMethods
#escaped_ilike, #escaped_like, #ilike, #like
Methods included from PatternMatchMethods
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, #clone, #eql?, #hash, inherited, #inspect
Constructor Details
#initialize(expression, sub) ⇒ Subscript
Set the array column and subscripts to the given arguments
1816 1817 1818 1819 1820 |
# File 'lib/sequel/sql.rb', line 1816 def initialize(expression, sub) @expression = expression @sub = sub freeze end |
Instance Attribute Details
#expression ⇒ Object (readonly) Also known as: f
The SQL array column
1809 1810 1811 |
# File 'lib/sequel/sql.rb', line 1809 def expression @expression end |
#sub ⇒ Object (readonly)
The array of subscripts to use (should be an array of numbers)
1813 1814 1815 |
# File 'lib/sequel/sql.rb', line 1813 def sub @sub end |
Instance Method Details
#[](sub) ⇒ Object
Create a new Subscript by accessing a subarray of a multidimensional array.
Sequel[:a].sql_subscript(2) # a[2]
Sequel[:a].sql_subscript(2)[1] # a[2][1]
1836 1837 1838 |
# File 'lib/sequel/sql.rb', line 1836 def [](sub) Subscript.new(self, Array(sub)) end |
#|(sub) ⇒ Object
Create a new Subscript appending the given subscript(s) to the current array of subscripts.
Sequel[:a].sql_subscript(2) # a[2]
Sequel[:a].sql_subscript(2) | 1 # a[2, 1]
1827 1828 1829 |
# File 'lib/sequel/sql.rb', line 1827 def |(sub) Subscript.new(@expression, @sub + Array(sub)) end |