Class Sequel::SQL::Subscript
In: lib/sequel/sql.rb
Parent: GenericExpression

Represents an SQL array access, with multiple possible arguments.

Methods

[]   new   |  

External Aliases

expression -> f

Attributes

expression  [R]  The SQL array column
sub  [R]  The array of subscripts to use (should be an array of numbers)

Public Class methods

Set the array column and subscripts to the given arguments

[Source]

      # File lib/sequel/sql.rb, line 1745
1745:       def initialize(expression, sub)
1746:         @expression = expression
1747:         @sub = sub
1748:         freeze
1749:       end

Public Instance methods

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]

[Source]

      # File lib/sequel/sql.rb, line 1765
1765:       def [](sub)
1766:         Subscript.new(self, Array(sub))
1767:       end

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]

[Source]

      # File lib/sequel/sql.rb, line 1756
1756:       def |(sub)
1757:         Subscript.new(@expression, @sub + Array(sub))
1758:       end

[Validate]