We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2cd43cb commit b43eaa9Copy full SHA for b43eaa9
lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -353,7 +353,7 @@ def add_limit_offset!(sql, options)
353
end
354
# The business of adding limit/offset
355
if options[:limit] and options[:offset]
356
- total_rows = select_value("SELECT count(*) as TotalRows from (#{sql.gsub(/\bSELECT(\s+DISTINCT)?\b/i, "SELECT#{$1} TOP 1000000000")}) tally").to_i
+ total_rows = select_value("SELECT count(*) as TotalRows from (#{sql.sub(/\bSELECT(\s+DISTINCT)?\b/i, "SELECT#{$1} TOP 1000000000")}) tally").to_i
357
if (options[:limit] + options[:offset]) >= total_rows
358
options[:limit] = (total_rows - options[:offset] >= 0) ? (total_rows - options[:offset]) : 0
359
0 commit comments