class Sequel::Postgres::PGArray

  1. lib/sequel/extensions/pg_array.rb
  2. lib/sequel/extensions/pg_array_ops.rb
  3. lib/sequel/extensions/pg_range.rb
  4. show all
Superclass: DelegateClass(Array)

Represents a PostgreSQL array column value.



Public Class

  1. new

Public Instance

  1. array_type
  2. op
  3. sql_literal_append

Included modules

  1. Sequel::SQL::AliasMethods


array_type [RW]

The type of this array. May be nil if no type was given. If a type is provided, the array is automatically casted to this type when literalizing. This type is the underlying type, not the array type itself, so for an int4[] database type, it should be :int4 or 'int4'

Public Class methods

new(array, type=nil)

Set the array to delegate to, and a database type.

[show source]
    # File lib/sequel/extensions/pg_array.rb
439 def initialize(array, type=nil)
440   super(array)
441   @array_type = type
442 end

Public Instance methods


Wrap the PGArray instance in an ArrayOp, allowing you to easily use the PostgreSQL array functions and operators with literal arrays.

[show source]
    # File lib/sequel/extensions/pg_array_ops.rb
294 def op
296 end
sql_literal_append(ds, sql)

Append the array SQL to the given sql string. If the receiver has a type, add a cast to the database array type.

[show source]
    # File lib/sequel/extensions/pg_array.rb
447 def sql_literal_append(ds, sql)
448   at = array_type
449   if empty? && at
450     sql << "'{}'"
451   else
452     sql << "ARRAY"
453     _literal_append(sql, ds, to_a)
454   end
455   if at
456     sql << '::' << at.to_s << '[]'
457   end
458 end