class Sequel::ODBC::Dataset
Public Instance Methods
fetch_rows(sql) { |hash| ... }
click to toggle source
# File lib/sequel/adapters/odbc.rb 89 def fetch_rows(sql) 90 execute(sql) do |s| 91 i = -1 92 cols = s.columns(true).map{|c| [output_identifier(c.name), c.type, i+=1]} 93 columns = cols.map{|c| c[0]} 94 self.columns = columns 95 s.each do |row| 96 hash = {} 97 cols.each{|n,t,j| hash[n] = convert_odbc_value(row[j], t)} 98 yield hash 99 end 100 end 101 self 102 end
Private Instance Methods
convert_odbc_value(v, t)
click to toggle source
# File lib/sequel/adapters/odbc.rb 106 def convert_odbc_value(v, t) 107 # When fetching a result set, the Ruby ODBC driver converts all ODBC 108 # SQL types to an equivalent Ruby type; with the exception of 109 # SQL_TYPE_DATE, SQL_TYPE_TIME and SQL_TYPE_TIMESTAMP. 110 # 111 # The conversions below are consistent with the mappings in 112 # ODBCColumn#mapSqlTypeToGenericType and Column#klass. 113 case v 114 when ::ODBC::TimeStamp 115 db.to_application_timestamp([v.year, v.month, v.day, v.hour, v.minute, v.second, v.fraction]) 116 when ::ODBC::Time 117 Sequel::SQLTime.create(v.hour, v.minute, v.second) 118 when ::ODBC::Date 119 Date.new(v.year, v.month, v.day) 120 else 121 if t == ::ODBC::SQL_BIT 122 v == 1 123 else 124 v 125 end 126 end 127 end
default_timestamp_format()
click to toggle source
# File lib/sequel/adapters/odbc.rb 129 def default_timestamp_format 130 "{ts '%Y-%m-%d %H:%M:%S'}" 131 end
literal_date(v)
click to toggle source
# File lib/sequel/adapters/odbc.rb 133 def literal_date(v) 134 v.strftime("{d '%Y-%m-%d'}") 135 end
literal_false()
click to toggle source
# File lib/sequel/adapters/odbc.rb 137 def literal_false 138 '0' 139 end
literal_true()
click to toggle source
# File lib/sequel/adapters/odbc.rb 141 def literal_true 142 '1' 143 end