ActiveRecord SQLServer Adapter Patch Accepted

If you’re like me and work on a Ruby on Rails application which is backed by SQLServer (don’t ask!), then you may be interested in this. If not, then go way you lucky bastard!

As we all know, SQLServer is a huge PITA (no limit/offset? WTF?) and up until recently, the ActiveRecord SQLServer Adapter didn’t even ship with Rails. Yeah, there are a lot of them them out there, but they all have their own problems. Anyway, thanks to all the great work done by Ken Collins and company, as of Rails 2.2, the ActiveRecord SQLServer Adapter is back!

I was so happy when I heard this that I instantly installed it over top of our Frankensteined version to see if it would resovle the countless issues we’ve had to deal with. Things were going smoothly and I was jubilant until I discovered that this column quoting issue was still hanging around and causingĀ  errors like this:

DBI::DatabaseError: 42000 (102) [FreeTDS][SQL Server]Incorrect syntax near ‘.’.: SELECT * FROM (SELECT TOP 10 * FROM (SELECT TOP 10 [people].* FROM [people] ORDER BY people.[id] ASC) AS tmp1 ORDER BY people.[[id]] DESC) AS tmp2 ORDER BY people.[[id]] ASC

I promptly submitted my glorious 1 LOC patch (actually, it’s more than one line if you include the test case!) and Ken was kind enough to include it in the latest release!

w00t!

Tags: , ,

Leave a Reply