Class Index [+]

Quicksearch

Sequel::Postgres::ArrayOp

The ArrayOp class is a simple container for a single object that defines methods that yield Sequel expression objects representing PostgreSQL array operators and functions.

In the method documentation examples, assume that:

  array_op = :array.pg_array

Constants

CONCAT
CONTAINS
CONTAINED_BY
OVERLAPS

Public Instance Methods

[](key) click to toggle source

Access a member of the array, returns an SQL::Subscript instance:

  array_op[1] # array[1]
    # File lib/sequel/extensions/pg_array_ops.rb, line 58
58:       def [](key)
59:         Sequel::SQL::Subscript.new(self, [key])
60:       end
all() click to toggle source

Call the ALL function:

  array_op.all # ALL(array)

Usually used like:

  dataset.where(1=>array_op.all)
  # WHERE (1 = ALL(array))
    # File lib/sequel/extensions/pg_array_ops.rb, line 70
70:       def all
71:         function(:ALL)
72:       end
any() click to toggle source

Call the ANY function:

  array_op.all # ANY(array)

Usually used like:

  dataset.where(1=>array_op.any)
  # WHERE (1 = ANY(array))
    # File lib/sequel/extensions/pg_array_ops.rb, line 82
82:       def any
83:         function(:ANY)
84:       end
concat(other) click to toggle source
Alias for: push
contained_by(other) click to toggle source

Use the contained by (<@) operator:

  array_op.contained_by(:a) # (array <@ a)
    # File lib/sequel/extensions/pg_array_ops.rb, line 96
96:       def contained_by(other)
97:         bool_op(CONTAINED_BY, other)
98:       end
contains(other) click to toggle source

Use the contains (@>) operator:

  array_op.contains(:a) # (array @> a)
    # File lib/sequel/extensions/pg_array_ops.rb, line 89
89:       def contains(other)
90:         bool_op(CONTAINS, other)
91:       end
dims() click to toggle source

Call the array_dims method:

  array_op.dims # array_dims(array)
     # File lib/sequel/extensions/pg_array_ops.rb, line 103
103:       def dims
104:         function(:array_dims)
105:       end
join(joiner="", null=nil) click to toggle source
Alias for: to_string
length(dimension = 1) click to toggle source

Call the array_length method:

  array_op.length    # array_length(array, 1)
  array_op.length(2) # array_length(array, 2)
     # File lib/sequel/extensions/pg_array_ops.rb, line 111
111:       def length(dimension = 1)
112:         function(:array_length, dimension)
113:       end
lower(dimension = 1) click to toggle source

Call the array_lower method:

  array_op.lower    # array_lower(array, 1)
  array_op.lower(2) # array_lower(array, 2)
     # File lib/sequel/extensions/pg_array_ops.rb, line 119
119:       def lower(dimension = 1)
120:         function(:array_lower, dimension)
121:       end
overlaps(other) click to toggle source

Use the overlaps (&&) operator:

  array_op.overlaps(:a) # (array && a)
     # File lib/sequel/extensions/pg_array_ops.rb, line 126
126:       def overlaps(other)
127:         bool_op(OVERLAPS, other)
128:       end
pg_array() click to toggle source

Return the receiver.

     # File lib/sequel/extensions/pg_array_ops.rb, line 140
140:       def pg_array
141:         self
142:       end
push(other) click to toggle source

Use the concatentation (||) operator:

  array_op.push(:a) # (array || a)
  array_op.concat(:a) # (array || a)
     # File lib/sequel/extensions/pg_array_ops.rb, line 134
134:       def push(other)
135:         array_op(CONCAT, [self, other])
136:       end
Also aliased as: concat
to_string(joiner="", null=nil) click to toggle source

Call the array_to_string method:

  array_op.join           # array_to_string(array, '', NULL)
  array_op.to_string      # array_to_string(array, '', NULL)
  array_op.join(":")      # array_to_string(array, ':', NULL)
  array_op.join(":", "*") # array_to_string(array, ':', '*')
     # File lib/sequel/extensions/pg_array_ops.rb, line 150
150:       def to_string(joiner="", null=nil)
151:         function(:array_to_string, joiner, null)
152:       end
Also aliased as: join
unnest() click to toggle source

Call the unnest method:

  array_op.unnest # unnest(array)
     # File lib/sequel/extensions/pg_array_ops.rb, line 158
158:       def unnest
159:         function(:unnest)
160:       end
unshift(other) click to toggle source

Use the concatentation (||) operator, reversing the order:

  array_op.unshift(:a) # (a || array)
     # File lib/sequel/extensions/pg_array_ops.rb, line 165
165:       def unshift(other)
166:         array_op(CONCAT, [other, self])
167:       end

Private Instance Methods

array_op(str, args) click to toggle source

Return a placeholder literal with the given str and args, wrapped in an ArrayOp, used by operators that return arrays.

     # File lib/sequel/extensions/pg_array_ops.rb, line 173
173:       def array_op(str, args)
174:         ArrayOp.new(Sequel::SQL::PlaceholderLiteralString.new(str, args))
175:       end
bool_op(str, other) click to toggle source

Return a placeholder literal with the given str and args, wrapped in a boolean expression, used by operators that return booleans.

     # File lib/sequel/extensions/pg_array_ops.rb, line 179
179:       def bool_op(str, other)
180:         Sequel::SQL::BooleanExpression.new(:NOOP, Sequel::SQL::PlaceholderLiteralString.new(str, [value, other]))
181:       end
function(name, *args) click to toggle source

Return a function with the given name, and the receiver as the first argument, with any additional arguments given.

     # File lib/sequel/extensions/pg_array_ops.rb, line 185
185:       def function(name, *args)
186:         SQL::Function.new(name, self, *args)
187:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.