diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-02-09 21:42:29 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-02-09 21:42:29 +0000 |
commit | 60793cc27f4e930c3139d4ab296c5df443c0623c (patch) | |
tree | 1a8198f29c84266748114cf2a06a2e7241a0e19e /activerecord | |
parent | 76540822609415dc5cfa8ea31bfafea602373a27 (diff) | |
download | rails-60793cc27f4e930c3139d4ab296c5df443c0623c.tar.gz rails-60793cc27f4e930c3139d4ab296c5df443c0623c.tar.bz2 rails-60793cc27f4e930c3139d4ab296c5df443c0623c.zip |
SQLServer: more compatible limit/offset emulation. Closes #3779.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index c3bae2c841..32f71130d6 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* SQLServer: more compatible limit/offset emulation. #3779 [Tom Ward] + * Polymorphic join support for has_one associations (has_one :foo, :as => :bar) #3785 [Rick Olson] * PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org] diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb index 9d7174007c..708ec086fd 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb @@ -375,7 +375,9 @@ module ActiveRecord sql << " ) AS tmp2" end elsif sql !~ /^\s*SELECT (@@|COUNT\()/i - sql.sub!(/^\s*SELECT/i, "SELECT TOP #{options[:limit]}") unless options[:limit].nil? + sql.sub!(/^\s*SELECT([\s]*distinct)?/i) do + "SELECT#{$1} TOP #{options[:limit]}" + end unless options[:limit].nil? end end |