class Sequel::TinyTDS::Dataset

  1. lib/sequel/adapters/tinytds.rb
Superclass: Dataset

Methods

Public Instance

  1. fetch_rows

Constants

PreparedStatementMethods = prepared_statements_module("sql = prepared_sql; opts = Hash[opts]; opts[:arguments] = bind_arguments", ArgumentMapper)  

Public Instance methods

fetch_rows(sql)
[show source]
    # File lib/sequel/adapters/tinytds.rb
214 def fetch_rows(sql)
215   execute(sql) do |result|
216     # Mutating an array in the result is questionable, but supported
217     # by tiny_tds developers (tiny_tds issue #57)
218     columns = result.fields.map!{|c| output_identifier(c)}
219     if columns.empty?
220       args = []
221       args << {:timezone=>:utc} if db.timezone == :utc
222       cols = nil
223       result.each(*args) do |r|
224         unless cols
225           cols = result.fields.map{|c| [c, output_identifier(c)]}
226           self.columns = columns = cols.map(&:last)
227         end
228         h = {}
229         cols.each do |s, sym|
230           h[sym] = r[s]
231         end
232         yield h
233       end
234     else
235       self.columns = columns
236       if db.timezone == :utc
237         result.each(:timezone=>:utc){|r| yield r}
238       else
239         result.each{|r| yield r}
240       end
241     end
242   end
243   self
244 end