Skip to content
This repository
Browse code

Handle multiline sql when adding limit offset

  • Loading branch information...
commit 273f6c515b9a7cfc15b8fc895b43919b5eaefd61 1 parent 9700856
James Walker jcosmo authored

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/jdbc_adapter/jdbc_mssql.rb
2  lib/jdbc_adapter/jdbc_mssql.rb
@@ -233,7 +233,7 @@ def add_limit_offset!(sql, options)
233 233 end_row = offset + limit.to_i
234 234 order = (options[:order] || determine_order_clause(sql))
235 235 sql.sub!(/ ORDER BY.*$/i, '')
236   - find_select = /\b(SELECT(?:\s+DISTINCT)?)\b(.*)/i
  236 + find_select = /\b(SELECT(?:\s+DISTINCT)?)\b(.*)/im
237 237 whole, select, rest_of_query = find_select.match(sql).to_a
238 238 if (start_row == 1) && (end_row ==1)
239 239 new_sql = "#{select} TOP 1 #{rest_of_query}"

0 comments on commit 273f6c5

Please sign in to comment.
Something went wrong with that request. Please try again.