module Sequel::Postgres::PGArray::DatabaseMethods

Constants

ESCAPE_RE
ESCAPE_REPLACEMENT

Public Class Methods

extended(db) click to toggle source

Reset the conversion procs when extending the Database object, so it will pick up the array convertors. This is only done for the native postgres adapter.

# File lib/sequel/extensions/pg_array.rb, line 103
def self.extended(db)
  db.reset_conversion_procs if db.respond_to?(:reset_conversion_procs)
end

Public Instance Methods

bound_variable_arg(arg, conn) click to toggle source

Handle arrays in bound variables

# File lib/sequel/extensions/pg_array.rb, line 108
def bound_variable_arg(arg, conn)
  case arg
  when PGArray
    bound_variable_array(arg.to_a)
  when Array
    bound_variable_array(arg)
  else
    super
  end
end
schema_column_type(db_type) click to toggle source

Make the column type detection deal with string and numeric array types.

# File lib/sequel/extensions/pg_array.rb, line 120
def schema_column_type(db_type)
  case db_type
  when %r\A(character( varying)?|text).*\[\]\z/o
    :string_array
  when %r\A(integer|bigint|smallint)\[\]\z/o
    :integer_array
  when %r\A(real|double precision)\[\]\z/o
    :float_array
  when %r\Anumeric.*\[\]\z/o
    :decimal_array
  else
    super
  end
end