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

Represents an SQL array access, with multiple possible arguments.

### Methods

[] new |

### Attributes

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

### Public Class methods

new(f, sub)

Set the array column and subscripts to the given arguments

[Source]

          # File lib/sequel/sql.rb, line 1369
    1369:       def initialize(f, sub)
    1370:         @f, @sub = f, sub
    1371:       end

### Public Instance methods

[](sub)

Create a new `Subscript` by accessing a subarray of a multidimensional array.

      :a.sql_subscript(2) # a[2]
      :a.sql_subscript(2)[1] # a[2][1]

[Source]

          # File lib/sequel/sql.rb, line 1387
    1387:       def [](sub)
    1388:         Subscript.new(self, Array(sub))
    1389:       end

|(sub)

Create a new `Subscript` appending the given subscript(s) the the current array of subscripts.

      :a.sql_subscript(2) # a[2]
      :a.sql_subscript(2) | 1 # a[2, 1]

[Source]

          # File lib/sequel/sql.rb, line 1378
    1378:       def |(sub)
    1379:         Subscript.new(@f, @sub + Array(sub))
    1380:       end

[Validate]