You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/active_record/connection_adapters/sqlserver_adapter.rb
+22-2Lines changed: 22 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -386,12 +386,32 @@ def quote_column_name(name)
386
386
end
387
387
388
388
defadd_limit_offset!(sql,options)
389
+
ifoptions[:offset]
390
+
raiseArgumentError,"offset should have a limit"unlessoptions[:limit]
391
+
unlessoptions[:offset].kind_of?Integer
392
+
ifoptions[:offset] =~ /^\d+$/
393
+
options[:offset]=options[:offset].to_i
394
+
else
395
+
raiseArgumentError,"offset should be an integer"
396
+
end
397
+
end
398
+
end
399
+
400
+
unlessoptions[:limit].kind_of?Integer
401
+
# is it just a string which should be an integer?
402
+
ifoptions[:limit] =~ /^\d+$/
403
+
options[:limit]=options[:limit].to_i
404
+
else
405
+
raiseArgumentError,"limit should be an integer"
406
+
end
407
+
end
408
+
389
409
ifoptions[:limit]andoptions[:offset]
390
410
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
0 commit comments