Class: Sequel::SQL::Subscript

Inherits:
Expression show all
Defined in:
lib/sequel_core/sql.rb

Overview

Represents an SQL array access, with multiple possible arguments.

Constant Summary

Constants included from ColumnMethods

ColumnMethods::AS, ColumnMethods::ASC, ColumnMethods::DESC

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#lit

Methods included from ColumnMethods

#as, #asc, #cast_as, #desc

Constructor Details

#initialize(f, sub) ⇒ Subscript

Set the attributes to the given arguments



475
476
477
# File 'lib/sequel_core/sql.rb', line 475

def initialize(f, sub)
  @f, @sub = f, sub
end

Instance Attribute Details

#fObject (readonly)

The SQL array column



469
470
471
# File 'lib/sequel_core/sql.rb', line 469

def f
  @f
end

#subObject (readonly)

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



472
473
474
# File 'lib/sequel_core/sql.rb', line 472

def sub
  @sub
end

Instance Method Details

#to_s(ds) ⇒ Object

Delegate the creation of the resulting SQL to the given dataset, since it may be database dependent.



487
488
489
# File 'lib/sequel_core/sql.rb', line 487

def to_s(ds)
  ds.subscript_sql(self)
end

#|(sub) ⇒ Object

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



481
482
483
# File 'lib/sequel_core/sql.rb', line 481

def |(sub)
  Subscript.new(@f, @sub + Array(sub))
end