class Sequel::TinyTDS::Dataset

Constants

PreparedStatementMethods

Public Instance Methods

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

Private Instance Methods

literal_string_append(sql, v) click to toggle source

Properly escape the given string

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