pg_inet.rb

lib/sequel/extensions/pg_inet.rb
Last Update: 2022-10-30 19:13:54 -0700

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 and jdbc/postgresql adapters, so that when inet/cidr fields are retrieved, they are returned as IPAddr instances.

To use this extension, load it into your database:

DB.extension :pg_inet

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.

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

Related module: Sequel::Postgres::InetDatabaseMethods

Required files

  1. ipaddr