Module | Sequel::Plugins::PgTypecastOnLoad
In: | lib/sequel/plugins/pg_typecast_on_load.rb

The PgTypecastOnLoad plugin exists because when you connect to PostgreSQL using the do, swift, or jdbc adapter, Sequel doesn‘t have complete control over typecasting, and may return columns as strings instead of how the native postgres adapter would typecast them. This is mostly needed for the additional support that the pg_* extensions add for advanced PostgreSQL types such as arrays.

This plugin modifies Model#set_values to do the same conversion that the native postgres adapter would do for all columns given. You can either specify the columns to typecast on load in the plugin call itself, or afterwards using add_pg_typecast_on_load_columns:

      # aliases => text[] column
      # config => hstore column

      Album.plugin :pg_typecast_on_load, :aliases, :config
      # or:
      Album.plugin :pg_typecast_on_load
      Album.add_pg_typecast_on_load_columns :aliases, :config

This plugin only handles values that the adapter returns as strings. If the adapter returns a value other than a string for a column, that value will be used directly without typecasting.

### Methods

configure

### Classes and Modules

Module Sequel::Plugins::PgTypecastOnLoad::ClassMethods
Module Sequel::Plugins::PgTypecastOnLoad::InstanceMethods

### Public Class methods

configure(model, *columns)

Call add_pg_typecast_on_load_columns on the passed column arguments.

[Source]

        # File lib/sequel/plugins/pg_typecast_on_load.rb, line 28
    28:       def self.configure(model, *columns)
    29:         model.instance_eval do
    30:           @pg_typecast_on_load_columns ||= []
    31:           add_pg_typecast_on_load_columns(*columns)
    32:         end
    33:       end

[Validate]