Using the OpenLink Rails ODBC Adapter With PostgreSQL

Table of Contents

Supported OpenLink Driver Versions

OpenLink's v6 ODBC driver must be used. The v5.2 driver is not supported due to problems with Postgres session management. The problems are caused by each hstmt using a separate Postgres session. In the v6 driver, all hstmts belonging to the same hdbc share the same Postgres session; so the driver is free from these issues.

Type Mappings

ActiveRecord defines a number of abstract data types. These and the corresponding Ruby data types are listed in the table below. Which native database types the abstract types map to will depend to some extent on the underlying ODBC driver used by the OpenLink Rails ODBC Adapter. The native type mappings for the OpenLink PostgreSQL agents/Lite drivers are shown below.

Active Record abstract type Ruby type PostgreSQL type
:primary_key - serial primary key
:string String varchar(255)
:boolean Object bool
:datetime Time timestamp
:time Time time
:timestamp Time timestamp
:date Date date
:text String text
:integer Fixnum int4
:float Float float4
:binary String bytea
:decimal BigDecimal numeric

It is suggested you use these native database types when creating tables to support your Rails models.

Native PostgreSQL ODBC Driver

The native PostgreSQL driver (8.02.02) is not currently supported due to problems with the ODBC driver itself. The SQLGetTypeInfo output includes a non-existent datatype 'lo' which maps to SQL_LONGVARBINARY. This in turn creates a nonsensical mapping in the Rails adapter, mapping the AR generic type :binary to the non-existent PostgreSQL native type 'lo'.

ODBC-Rails and the ODBC-Rails website are Copyright (C) OpenLink Software 2006-2008