Notes for using the ODBC Adapter with Sybase

Type Mappings

Active Record abstract type Ruby type Sybase type
:primary_key - INT IDENTITY PRIMARY KEY
:string String VARCHAR(255)
:boolean Object BIT
:datetime Time DATETIME
:time Time TIME
:timestamp Time DATETIME
:date Date DATE
:text String TEXT
:integer Fixnum INT
:float Float REAL
:binary String IMAGE

It is suggested you use these native database types when creating tables to support your Rails models. Example table definitions are attached below:

Restrictions

Set the connection option :convert numeric_literals to true to avoid errors similar to: "Implicit conversion from datatype ‘VARCHAR’ to ‘INT’ is not allowed."

:boolean columns use the BIT SQL type, which does not allow nulls or indexes. If a DEFAULT is not specified for create_table, the column will be declared with DEFAULT 0.

Migrations are supported, but for ALTER TABLE commands to work, the database must have the database option ‘select into’ set to ‘true’ with sp_dboption. e.g.


    1> use mydb
    2> go
    1> master..sp_dboption mydb, "select into", true
    2> go
    1> checkpoint
    2> go

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