Skip to content

Commit 3d3b9eb

Browse files
committed
Testing out git editting. Making changes to add_limit_offset!
1 parent a764ac1 commit 3d3b9eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ def quote_column_name(name)
386386
end
387387

388388
def add_limit_offset!(sql, options)
389-
if options[:limit] and options[:offset]
389+
if options[:limit] and options[:offset] and options[:offset] > 0
390390
total_rows = @connection.select_all("SELECT count(*) as TotalRows from (#{sql.gsub(/\bSELECT(\s+DISTINCT)?\b/i, "SELECT#{$1} TOP 1000000000")}) tally")[0][:TotalRows].to_i
391391
if (options[:limit] + options[:offset]) >= total_rows
392392
options[:limit] = (total_rows - options[:offset] >= 0) ? (total_rows - options[:offset]) : 0

0 commit comments

Comments
 (0)