# pg_inet.rb

Path: | lib/sequel/extensions/pg_inet.rb
Last Update: | Sun May 19 07:59:58 +0000 2013

The pg_inet extension adds support for Sequel to handle PostgreSQL‘s inet and cidr types using ruby‘s IPAddr class.

This extension integrates with Sequel‘s native postgres adapter, so that when inet/cidr fields are retrieved, they are returned as IPAddr instances

After loading the extension, you should extend your dataset with a module so that it correctly handles the inet/cidr type:

      DB.extension :pg_inet

If you are not using the native postgres adapter, you probably also want to use the typecast_on_load plugin in the model, and set it to typecast the inet/cidr column(s) on load.

This extension integrates with the pg_array extension. If you plan to use the inet[] or cidr[] types, load the pg_array extension before the pg_inet extension:

      DB.extension :pg_array, :pg_inet

This extension does not add special support for the macaddr type. Ruby doesn‘t have a stdlib class that represents mac addresses, so these will still be returned as strings. The exception to this is that the pg_array extension integration will recognize macaddr[] types return them as arrays of strings.

### Required files

ipaddr adapters/utils/pg_types

[Validate]