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 if rows = s.fetch_all 96 rows.each do |row| 97 hash = {} 98 cols.each{|n,t,j| hash[n] = convert_odbc_value(row[j], t)} 99 yield hash 100 end 101 end 102 end 103 self 104 end
Private Instance Methods
convert_odbc_value(v, t)
click to toggle source
# File lib/sequel/adapters/odbc.rb 108 def convert_odbc_value(v, t) 109 # When fetching a result set, the Ruby ODBC driver converts all ODBC 110 # SQL types to an equivalent Ruby type; with the exception of 111 # SQL_TYPE_DATE, SQL_TYPE_TIME and SQL_TYPE_TIMESTAMP. 112 # 113 # The conversions below are consistent with the mappings in 114 # ODBCColumn#mapSqlTypeToGenericType and Column#klass. 115 case v 116 when ::ODBC::TimeStamp 117 db.to_application_timestamp([v.year, v.month, v.day, v.hour, v.minute, v.second, v.fraction]) 118 when ::ODBC::Time 119 Sequel::SQLTime.create(v.hour, v.minute, v.second) 120 when ::ODBC::Date 121 Date.new(v.year, v.month, v.day) 122 else 123 if t == ::ODBC::SQL_BIT 124 v == 1 125 else 126 v 127 end 128 end 129 end
default_timestamp_format()
click to toggle source
# File lib/sequel/adapters/odbc.rb 131 def default_timestamp_format 132 "{ts '%Y-%m-%d %H:%M:%S'}" 133 end
literal_date(v)
click to toggle source
# File lib/sequel/adapters/odbc.rb 135 def literal_date(v) 136 v.strftime("{d '%Y-%m-%d'}") 137 end
literal_false()
click to toggle source
# File lib/sequel/adapters/odbc.rb 139 def literal_false 140 '0' 141 end
literal_true()
click to toggle source
# File lib/sequel/adapters/odbc.rb 143 def literal_true 144 '1' 145 end