class Sequel::SQL::Subscript

  1. lib/sequel/sql.rb
Superclass: GenericExpression

Represents an SQL array access, with multiple possible arguments.

Methods

Public Class

  1. new

Public Instance

  1. []
  2. expression
  3. sub
  4. |

Attributes

expression [R]

The SQL array column

f [R]

The SQL array column

sub [R]

The array of subscripts to use (should be an array of numbers)

Public Class methods

new(expression, sub)

Set the array column and subscripts to the given arguments

[show source]
     # File lib/sequel/sql.rb
1811 def initialize(expression, sub)
1812   @expression = expression
1813   @sub = sub
1814   freeze
1815 end

Public Instance methods

[](sub)

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]
[show source]
     # File lib/sequel/sql.rb
1831 def [](sub)
1832   Subscript.new(self, Array(sub))
1833 end
|(sub)

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]
[show source]
     # File lib/sequel/sql.rb
1822 def |(sub)
1823   Subscript.new(@expression, @sub + Array(sub))
1824 end