@@ -4,7 +4,7 @@ module Sqlserver
44 module DatabaseStatements
55
66 def select_rows ( sql , name = nil , binds = [ ] )
7- raw_select sql , name , binds , fetch : :rows
7+ do_exec_query sql , name , binds , fetch : :rows
88 end
99
1010 def execute ( sql , name = nil )
@@ -327,7 +327,13 @@ def do_execute(sql, name = 'SQL')
327327 end
328328 end
329329
330- def do_exec_query ( sql , name , binds )
330+ def do_exec_query ( sql , name , binds , options = { } )
331+ # This allows non-AR code to utilize the binds
332+ # handling code, e.g. select_rows()
333+ if options [ :fetch ] != :rows
334+ options [ :ar_result ] = true
335+ end
336+
331337 explaining = name == 'EXPLAIN'
332338 names_and_types = [ ]
333339 params = [ ]
@@ -358,7 +364,7 @@ def do_exec_query(sql, name, binds)
358364 sql = "EXEC sp_executesql #{ quote ( sql ) } "
359365 sql << ", #{ quote ( names_and_types . join ( ', ' ) ) } , #{ params . join ( ', ' ) } " unless binds . empty?
360366 end
361- raw_select sql , name , binds , ar_result : true
367+ raw_select sql , name , binds , options
362368 end
363369
364370 def raw_connection_do ( sql )
0 commit comments