File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
lib/active_record/connection_adapters Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -338,14 +338,12 @@ def add_limit_offset!(sql, options)
338338 else
339339 sql << ") AS tmp2"
340340 end
341- elsif sql !~ /^\s *SELECT (@@|COUNT\( )/i
342- unless options [ :limit ] . nil? || options [ :limit ] < 1
343- if md = sql . match ( /^(\s *SELECT)(\s +DISTINCT)?(.*)/im )
344- sql . replace "#{ md [ 1 ] } #{ md [ 2 ] } TOP #{ options [ :limit ] } #{ md [ 3 ] } "
345- else
346- # Account for building SQL fragments without SELECT yet. See #update_all and #limited_update_conditions.
347- sql . replace "TOP #{ options [ :limit ] } #{ sql } "
348- end
341+ elsif options [ :limit ] && sql !~ /^\s *SELECT (@@|COUNT\( )/i
342+ if md = sql . match ( /^(\s *SELECT)(\s +DISTINCT)?(.*)/im )
343+ sql . replace "#{ md [ 1 ] } #{ md [ 2 ] } TOP #{ options [ :limit ] } #{ md [ 3 ] } "
344+ else
345+ # Account for building SQL fragments without SELECT yet. See #update_all and #limited_update_conditions.
346+ sql . replace "TOP #{ options [ :limit ] } #{ sql } "
349347 end
350348 end
351349 end
You can’t perform that action at this time.
0 commit comments