Using the OpenLink Rails ODBC Adapter with Sybase
Table of Contents
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 Sybase (TDS) agents/Lite drivers are shown below.
|Active Record abstract type||Ruby type||Sybase type|
|:primary_key||-||INT IDENTITY PRIMARY KEY|
It is suggested you use these native database types when creating tables to support your Rails models. Example table definitions are attached below:
- sybase_odbc.sql These are the table definitions used for creating fixtures during testing - similar fixture definitions can be found for other databases in the ActiveRecord sources under active-record-root/test/fixtures/db_definitions.
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.
1> use mydb 2> go 1> master..sp_dboption mydb, "select into", true 2> go 1> checkpoint 2> go