Permalink
Browse files

SQLServer: more compatible limit/offset emulation. Closes #3779.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 7654082 commit 60793cc27f4e930c3139d4ab296c5df443c0623c @jeremy jeremy committed Feb 9, 2006
@@ -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]
@@ -375,7 +375,9 @@ def add_limit_offset!(sql, options)
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

0 comments on commit 60793cc

Please sign in to comment.