[Ironruby-core] Ironruby on Rails with SQL Azure

Ameer Deen lists at ruby-forum.com
Thu Sep 2 07:54:19 EDT 2010

Got it. There's a small issue with sqlserver_adapter.rb and the way 
Micrsoft Azure advertises it's version.

There is a database_year function that tries to determine the version of 
SQL Server from the output of the following query:

"SELECT @@version"

For Non Azure SQL Server databases, the output is similar to the 

"Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (Intel X86)   ..<blah 

the database_year funtion grabs the SQL Server version from the 4 digits 
following the word "Microsoft SQL Server":

      DATABASE_VERSION_REGEXP     = /Microsoft SQL Server\s+(\d{4})/

      def database_year

In Azure, however, the query returns a different string:

"Microsoft SQL Azure (RTM) - 10.25.9386.0   ..<blah blah>"

That database_year function, as a result returns a nil string and 
breaks. As a test, I just changed the function to:

      def database_year

and I was able to connect my rails application to SQL Azure. There just 
needs to be a smarter way to ascertain the SQL Server version. Possible 
match up the 10.XX version number with the SQL Server 2005/2008 etc 

Thanks very much for the help.


Posted via http://www.ruby-forum.com/.

More information about the Ironruby-core mailing list