rails-sqlserver/activerecord-sqlserver-adapter — pull request #171 by metalbot (2012-03-08 15:50:26+00:00)
Title: Patch for issue #167 problem with exists? on queries using an offset.

https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/167

Summary:

calling exists? on a model that has an offset fails, because there is an unnamed column that is created in rails to select "1" in exists?. This is problematic for us, since SQL Server doesn't like unnamed columns in subqueries, and we have to use subqueries to manage offset.

This fix is something of a hack, essentially checking if the node that we are visiting is "1", and appending a column alias.

There has been a proposal to fix this in rails:

Rails Issue: https://github.com/rails/rails/issues/1623

Pull Request to Rails: https://github.com/rails/rails/pull/2062

I've got mixed feelings about this. It's obviously easier to fix this in rails, but until the pull request is accepted, I'd rather not have to play catch up to maintain a monkey-patched version of rails.

Also open to the possibility that there is a better place to fix this.