Class/Module 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

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 86
def [](key)
  s = Sequel::SQL::Subscript.new(self, [key])
  s = ArrayOp.new(s) if key.is_a?(Range)
  s
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 100
def all
  function(:ALL)
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 112
def any
  function(:ANY)
end
cardinality() click to toggle source

Call the cardinality method:

array_op.cardinality # cardinality(array)
# File lib/sequel/extensions/pg_array_ops.rb, line 119
def cardinality
  function(:cardinality)
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 133
def contained_by(other)
  bool_op(CONTAINED_BY, wrap_array(other))
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 126
def contains(other)
  bool_op(CONTAINS, wrap_array(other))
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 140
def dims
  function(:array_dims)
end
hstore(arg=(no_arg_given=true; nil)) click to toggle source

Convert the array into an hstore using the hstore function. If given an argument, use the two array form:

array_op.hstore          # hstore(array)
array_op.hstore(:array2) # hstore(array, array2)
# File lib/sequel/extensions/pg_array_ops.rb, line 149
def hstore(arg=(no_arg_given=true; nil))
  v = if no_arg_given
    Sequel.function(:hstore, self)
  else
    Sequel.function(:hstore, self, wrap_array(arg))
  end
  if Sequel.respond_to?(:hstore_op)
    v = Sequel.hstore_op(v)
  end
  v
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 165
def length(dimension = 1)
  function(:array_length, dimension)
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 173
def lower(dimension = 1)
  function(:array_lower, dimension)
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 180
def overlaps(other)
  bool_op(OVERLAPS, wrap_array(other))
end
pg_array() click to toggle source

Return the receiver.

# File lib/sequel/extensions/pg_array_ops.rb, line 194
def pg_array
  self
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 188
def push(other)
  array_op(CONCAT, [self, wrap_array(other)])
end
Also aliased as: concat
remove(element) click to toggle source

Remove the given element from the array:

array_op.remove(1) # array_remove(array, 1)
# File lib/sequel/extensions/pg_array_ops.rb, line 201
def remove(element)
  ArrayOp.new(function(:array_remove, element))
end
replace(element, replacement) click to toggle source

Replace the given element in the array with another element:

array_op.replace(1, 2) # array_replace(array, 1, 2)
# File lib/sequel/extensions/pg_array_ops.rb, line 209
def replace(element, replacement)
  ArrayOp.new(function(:array_replace, element, replacement))
end
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 219
def to_string(joiner="", null=nil)
  function(:array_to_string, joiner, null)
end
Also aliased as: join
unnest(*args) click to toggle source

Call the unnest method:

array_op.unnest # unnest(array)
# File lib/sequel/extensions/pg_array_ops.rb, line 227
def unnest(*args)
  function(:unnest, *args.map{|a| wrap_array(a)})
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 234
def unshift(other)
  array_op(CONCAT, [wrap_array(other), self])
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.