Last Modified
  2016-09-30 19:32:14 +0000
Requires
  - active_support/duration
  - adapters/utils/pg_types

## Description

The pg_interval extension adds support for PostgreSQL's interval type.

This extension integrates with Sequel's native postgres adapter, so that when interval type values are retrieved, they are parsed and returned as instances of ActiveSupport::Duration.

In addition to the parser, this extension adds literalizers for ActiveSupport::Duration that use the standard Sequel literalization callbacks, so they work on all adapters.

If you would like to use interval columns in your model objects, you probably want to modify the typecasting so that it recognizes and correctly handles the interval columns, which you can do by:

    DB.extension :pg_interval

If you are not using the native postgres adapter and are using interval types as model column values you probably should use the pg_typecast_on_load plugin if the column values are returned as a string.

This extension integrates with the pg_array extension. If you plan to use arrays of interval types, load the pg_array extension before the pg_interval extension:

    DB.extension :pg_array, :pg_interval

The parser this extension uses requires that IntervalStyle for PostgreSQL is set to postgres (the default setting). If IntervalStyle is changed from the default setting, the parser will probably not work. The parser used is very simple, and is only designed to parse PostgreSQL's default output format, it is not designed to support all input formats that PostgreSQL supports.

See the schema modification guide for details on using interval columns in CREATE/ALTER TABLE statements.