Module Sequel::Postgres::PGArray::DatabaseMethods
In: lib/sequel/extensions/pg_array.rb

Methods

Constants

APOS = "'".freeze
DOUBLE_APOS = "''".freeze
ESCAPE_RE = /("|\\)/.freeze
ESCAPE_REPLACEMENT = '\\\\\1'.freeze
BLOB_RANGE = 1...-1

Public Class methods

Create the local hash of database type strings to schema type symbols, used for array types local to this database.

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 199
199:         def self.extended(db)
200:           db.instance_eval do
201:             @pg_array_schema_types ||= {}
202:             procs = conversion_procs
203:             procs[1115] = Creator.new("timestamp without time zone", procs[1114])
204:             procs[1185] = Creator.new("timestamp with time zone", procs[1184])
205:             copy_conversion_procs([143, 791, 1000, 1001, 1003, 1005, 1006, 1007, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1021, 1022, 1028, 1182, 1183, 1231, 1270, 1561, 1563, 2951])
206:             [:string_array, :integer_array, :decimal_array, :float_array, :boolean_array, :blob_array, :date_array, :time_array, :datetime_array].each do |v|
207:               @schema_type_classes[v] = PGArray
208:             end
209:           end
210:         end

Public Instance methods

Handle arrays in bound variables

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 213
213:         def bound_variable_arg(arg, conn)
214:           case arg
215:           when PGArray
216:             bound_variable_array(arg.to_a)
217:           when Array
218:             bound_variable_array(arg)
219:           else
220:             super
221:           end
222:         end

Register a database specific array type. This can be used to support different array types per Database. Use of this method does not affect global state, unlike PGArray.register. See PGArray.register for possible options.

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 228
228:         def register_array_type(db_type, opts=OPTS, &block)
229:           opts = {:type_procs=>conversion_procs, :typecast_method_map=>@pg_array_schema_types, :typecast_methods_module=>(class << self; self; end)}.merge!(opts)
230:           unless (opts.has_key?(:scalar_oid) || block) && opts.has_key?(:oid)
231:             array_oid, scalar_oid = from(:pg_type).where(:typname=>db_type.to_s).get([:typarray, :oid])
232:             opts[:scalar_oid] = scalar_oid unless opts.has_key?(:scalar_oid) || block
233:             opts[:oid] = array_oid unless opts.has_key?(:oid)
234:           end
235:           PGArray.register(db_type, opts, &block)
236:           @schema_type_classes["#{opts[:type_symbol] || db_type}_array""#{opts[:type_symbol] || db_type}_array"] = PGArray
237:           conversion_procs_updated
238:         end

Return PGArray if this type matches any supported array type.

[Source]

     # File lib/sequel/extensions/pg_array.rb, line 241
241:         def schema_type_class(type)
242:           super || (ARRAY_TYPES.each_value{|v| return PGArray if type == v}; nil)
243:         end

[Validate]