Using the OpenLink Rails ODBC Adapter with MySQL
Table of Contents
The native MySQL ODBC driver requires version 0.9991 (5-Aug-06) of the Ruby ODBC Bridge or greater.
Earlier versions of the bridge contain a bug in the transaction handling - a request to commit on a Rails connection commits all ODBC connections held by the ODBC environment (henv) associated with the Rails application. The ODBC feature which allows committing at the henv level does not work with the native MySQL driver (The SQLEndTran() call appears to succeed, but the MySQL trace shows that a COMMIT or ROLLBACK command does not reach the database). The OpenLink MySQL ODBC driver commits/rolls-back correctly at the henv level so the bug in the Ruby ODBC Bridge prior to release 0.9991 does not show up.
The bug shows up when running the tests in base_test.rb if transactional fixtures are used (i.e. if env var AR_NO_TX_FIXTURES is not set or is set to 'no').
v0.9991 of the Ruby ODBC Bridge commits/rolls-back at the ODBC connection level, as it should, not at the ODBC environment level.
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 MySQL agents/Lite drivers are shown below.
|Active Record abstract type||Ruby type||MySQL type|
|:primary_key||-||INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY|
|:boolean||Object||TINYINT (TINYINT(1) if :emulate_boolean connection option is true)|
It is suggested you use these native database types when creating tables to support your Rails models.