Class: Sequel::SQL::Subscript

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

Overview

Represents an SQL array access, with multiple possible arguments.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComplexExpressionMethods

#extract, #sql_boolean, #sql_number, #sql_string

Methods included from StringMethods

#ilike, #like

Methods included from BooleanMethods

#~

Methods included from OrderMethods

#asc, #desc

Methods included from CastMethods

#cast, #cast_numeric, #cast_string

Methods included from AliasMethods

#as

Methods inherited from Expression

#lit

Constructor Details

#initialize(f, sub) ⇒ Subscript

Set the attributes to the given arguments



714
715
716
# File 'lib/sequel_core/sql.rb', line 714

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

Instance Attribute Details

#fObject (readonly)

The SQL array column



708
709
710
# File 'lib/sequel_core/sql.rb', line 708

def f
  @f
end

#subObject (readonly)

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



711
712
713
# File 'lib/sequel_core/sql.rb', line 711

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.



726
727
728
# File 'lib/sequel_core/sql.rb', line 726

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.



720
721
722
# File 'lib/sequel_core/sql.rb', line 720

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