class Sequel::TinyTDS::Dataset

Constants

PreparedStatementMethods

Public Instance Methods

fetch_rows(sql) { |h| ... } click to toggle 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

Private Instance Methods

literal_string_append(sql, v) click to toggle source

Properly escape the given string

    # File lib/sequel/adapters/tinytds.rb
249 def literal_string_append(sql, v)
250   sql << (mssql_unicode_strings ? "N'" : "'")
251   sql << db.synchronize(@opts[:server]){|c| c.escape(v)}.gsub(/\\((?:\r\n)|\n)/, '\\\\\\\\\\1\\1') << "'"
252 end
prepared_statement_modules() click to toggle source
    # File lib/sequel/adapters/tinytds.rb
254 def prepared_statement_modules
255   [PreparedStatementMethods]
256 end