Monday, December 8, 2008

New rails 2.2.Sql Server adapter

There is a new SQL-Server adapter for active-record. The new features are the following :

- Enabled support for DDL transactions.
- Micro second support. Time#usec is automatically converted to SQL Server's 3.33 millisecond limitation.
- Datetime data types before type casting are represented correctly. For example: 1998-01-01 23:59:59.997
- Implementation for #disable_referential_integrity used by ActiveRecord's Fixtures class.
- Pessimistic locking suppot. See the #add_lock! method for details.
- Enabled #case_sensitive_equality_operator used by unique validations.
- Unicode character support for nchar, nvarchar and ntext data types.
- View support for table names, identity inserts, and column defaults.

to install it :

gem install rails-sqlserver-2000-2005-adapter -s http://gems.github.com

More info on article on railsinside.com or get the code on git

Update : After some tests I can confirm it does not function with SQL Server 2008, so stick to the normal adapter mentionned in my previous post if you are running SQL Server 2008 if you want to avoid the nice message saying "Currently only 2000 and 2005 are supported". Somehow frustrating if you have 2008 !

New Update : It seems that there is a workaround ! You can play with the constant SUPPORTED_VERSIONS by adding 2008 to it. The reason why it is not officially supported is that the author would like to rewrite the code to take advantage of the new features of SQL Server 2008. I can only thank him for this idea, let's hope the wait won't be too long !

By the way, this adapter is now also tested and improved for rails 2.3.2

3 comments:

Victor T. said...

Is there any place where I can see the use of this driver? I have now idea how to setup the database.yml for it to work.

Anonymous said...

Victor, I found this site which shows the new format:

http://rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html

In brief, an entry now looks like:

development:
   adapter: sqlserver
   mode: odbc
   dsn: sqlserverapp
   username: user
   password: secret
   host: mycomputer

It does require a DSN to be set up as well - though I am still looking for DSN-less configuration...

Hope that helps...

Paul O'Neill said...

Managing to construct a DSN-less entry:

development:
adapter: sqlserver
mode: ODBC
username: my_user_name
password: my_password
server: my_server
database: my_database
dsn: Driver={SQL Server};Server=my_server;Database=my_database;Uid=my_user_name
;Pwd=my_password
pool: 5
timeout: 500

(dsn entry should be on a single line, followed by pool entry...)

Enjoy!!!!