Class Sequel::Postgres::PGArray
In: lib/sequel/extensions/pg_array_ops.rb
lib/sequel/extensions/pg_array.rb
Parent: Object

Represents a PostgreSQL array column value.

Methods

new   op   sql_literal_append  

Included Modules

Sequel::SQL::AliasMethods

Classes and Modules

Module Sequel::Postgres::PGArray::DatabaseMethods
Class Sequel::Postgres::PGArray::Creator
Class Sequel::Postgres::PGArray::Parser

Attributes

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

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

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 419
419:       def initialize(array, type=nil)
420:         super(array)
421:         @array_type = type
422:       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.

[Source]

     # File lib/sequel/extensions/pg_array_ops.rb, line 286
286:         def op
287:           ArrayOp.new(self)
288:         end

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

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 427
427:       def sql_literal_append(ds, sql)
428:         at = array_type
429:         if empty? && at
430:           sql << "'{}'"
431:         else
432:           sql << "ARRAY"
433:           _literal_append(sql, ds, to_a)
434:         end
435:         if at
436:           sql << '::' << at.to_s << '[]'
437:         end
438:       end

[Validate]