| Class | Sequel::Postgres::ArrayOp |
| In: |
lib/sequel/extensions/pg_array_ops.rb
|
| Parent: | Sequel::SQL::Wrapper |
| CONCAT | = | ["(".freeze, " || ".freeze, ")".freeze].freeze |
| CONTAINS | = | ["(".freeze, " @> ".freeze, ")".freeze].freeze |
| CONTAINED_BY | = | ["(".freeze, " <@ ".freeze, ")".freeze].freeze |
| OVERLAPS | = | ["(".freeze, " && ".freeze, ")".freeze].freeze |
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 78
78: def [](key)
79: Sequel::SQL::Subscript.new(self, [key])
80: end
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 90
90: def all
91: function(:ALL)
92: end
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 102
102: def any
103: function(:ANY)
104: end
Use the contained by (<@) operator:
array_op.contained_by(:a) # (array <@ a)
# File lib/sequel/extensions/pg_array_ops.rb, line 116
116: def contained_by(other)
117: bool_op(CONTAINED_BY, wrap_array(other))
118: end
Call the array_dims method:
array_op.dims # array_dims(array)
# File lib/sequel/extensions/pg_array_ops.rb, line 123
123: def dims
124: function(:array_dims)
125: end
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 131
131: def length(dimension = 1)
132: function(:array_length, dimension)
133: end
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 139
139: def lower(dimension = 1)
140: function(:array_lower, dimension)
141: end
Return the receiver.
# File lib/sequel/extensions/pg_array_ops.rb, line 160
160: def pg_array
161: self
162: end
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 154
154: def push(other)
155: array_op(CONCAT, [self, wrap_array(other)])
156: end
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 170
170: def to_string(joiner="", null=nil)
171: function(:array_to_string, joiner, null)
172: end