class Sequel::TinyTDS::Dataset
Public Instance Methods
fetch_rows(sql) { |h| ... }
click to toggle source
Yield hashes with symbol keys, attempting to optimize for various cases.
# File lib/sequel/adapters/tinytds.rb, line 231 def fetch_rows(sql) execute(sql) do |result| columns = result.fields.map!{|c| output_identifier(c)} if columns.empty? args = [] args << {:timezone=>:utc} if db.timezone == :utc cols = nil result.each(*args) do |r| unless cols cols = result.fields.map{|c| [c, output_identifier(c)]} @columns = columns = cols.map{|c| c.last} end h = {} cols.each do |s, sym| h[sym] = r[s] end yield h end else @columns = columns if db.timezone == :utc result.each(:timezone=>:utc){|r| yield r} else result.each{|r| yield r} end end end self end
prepare(type, name=nil, *values)
click to toggle source
Create a named prepared statement that is stored in the database (and connection) for reuse.
# File lib/sequel/adapters/tinytds.rb, line 263 def prepare(type, name=nil, *values) ps = to_prepared_statement(type, values) ps.extend(PreparedStatementMethods) if name ps.prepared_statement_name = name db.set_prepared_statement(name, ps) end ps end
Private Instance Methods
literal_string_append(sql, v)
click to toggle source
Properly escape the given string v
.
# File lib/sequel/adapters/tinytds.rb, line 276 def literal_string_append(sql, v) sql << (mssql_unicode_strings ? UNICODE_STRING_START : APOS) sql << db.synchronize(@opts[:server]){|c| c.escape(v)}.gsub(BACKSLASH_CRLF_RE, BACKSLASH_CRLF_REPLACE) << APOS end