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
Methods
Public Instance
Constants
| CONCAT | = | ["(".freeze, " || ".freeze, ")".freeze].freeze | ||
| CONTAINED_BY | = | ["(".freeze, " <@ ".freeze, ")".freeze].freeze | ||
| CONTAINS | = | ["(".freeze, " @> ".freeze, ")".freeze].freeze | ||
| OVERLAPS | = | ["(".freeze, " && ".freeze, ")".freeze].freeze |
Public Instance methods
[]
(key)
Access a member of the array, returns an SQL::Subscript instance:
array_op[1] # array[1]
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 78 def [](key) Sequel::SQL::Subscript.new(self, [key]) end
all
()
Call the ALL function:
array_op.all # ALL(array)
Usually used like:
dataset.where(1=>array_op.all) # WHERE (1 = ALL(array))
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 90 def all function(:ALL) end
any
()
Call the ANY function:
array_op.all # ANY(array)
Usually used like:
dataset.where(1=>array_op.any) # WHERE (1 = ANY(array))
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 102 def any function(:ANY) end
contained_by
(other)
Use the contained by (<@) operator:
array_op.contained_by(:a) # (array <@ a)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 116 def contained_by(other) bool_op(CONTAINED_BY, wrap_array(other)) end
contains
(other)
Use the contains (@>) operator:
array_op.contains(:a) # (array @> a)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 109 def contains(other) bool_op(CONTAINS, wrap_array(other)) end
dims
()
Call the array_dims method:
array_op.dims # array_dims(array)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 123 def dims function(:array_dims) end
length
(dimension = 1)
Call the array_length method:
array_op.length # array_length(array, 1) array_op.length(2) # array_length(array, 2)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 131 def length(dimension = 1) function(:array_length, dimension) end
lower
(dimension = 1)
Call the array_lower method:
array_op.lower # array_lower(array, 1) array_op.lower(2) # array_lower(array, 2)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 139 def lower(dimension = 1) function(:array_lower, dimension) end
overlaps
(other)
Use the overlaps (&&) operator:
array_op.overlaps(:a) # (array && a)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 146 def overlaps(other) bool_op(OVERLAPS, wrap_array(other)) end
pg_array
()
Return the receiver.
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 160 def pg_array self end
push
(other)
Use the concatentation (||) operator:
array_op.push(:a) # (array || a) array_op.concat(:a) # (array || a)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 154 def push(other) array_op(CONCAT, [self, wrap_array(other)]) end
to_string
(joiner="", null=nil)
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, ':', '*')
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 170 def to_string(joiner="", null=nil) function(:array_to_string, joiner, null) end
unnest
()
Call the unnest method:
array_op.unnest # unnest(array)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 178 def unnest function(:unnest) end
unshift
(other)
Use the concatentation (||) operator, reversing the order:
array_op.unshift(:a) # (a || array)
[show source]
# File lib/sequel/extensions/pg_array_ops.rb, line 185 def unshift(other) array_op(CONCAT, [wrap_array(other), self]) end