Class | Sequel::Postgres::PGArray |
In: |
lib/sequel/extensions/pg_array.rb
lib/sequel/extensions/pg_array_ops.rb |
Parent: | DelegateClass(Array) |
Represents a PostgreSQL array column value.
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‘ |
Set the array to delegate to, and a database type.
# File lib/sequel/extensions/pg_array.rb, line 430 430: def initialize(array, type=nil) 431: super(array) 432: @array_type = type 433: end
Append the array SQL to the given sql string. If the receiver has a type, add a cast to the database array type.
# File lib/sequel/extensions/pg_array.rb, line 438 438: def sql_literal_append(ds, sql) 439: at = array_type 440: if empty? && at 441: sql << "'{}'" 442: else 443: sql << "ARRAY" 444: _literal_append(sql, ds, to_a) 445: end 446: if at 447: sql << '::' << at.to_s << '[]' 448: end 449: end