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.
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 419 419: def initialize(array, type=nil) 420: super(array) 421: @array_type = type 422: 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 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