class Sequel::ODBC::Dataset
Constants
- BOOL_FALSE
- BOOL_TRUE
- ODBC_DATE_FORMAT
- TIMESTAMP_FORMAT
Public Instance Methods
fetch_rows(sql) { |hash| ... }
click to toggle source
# File lib/sequel/adapters/odbc.rb, line 96 def fetch_rows(sql) execute(sql) do |s| i = -1 cols = s.columns(true).map{|c| [output_identifier(c.name), c.type, i+=1]} columns = cols.map{|c| c.at(0)} self.columns = columns if rows = s.fetch_all rows.each do |row| hash = {} cols.each{|n,t,j| hash[n] = convert_odbc_value(row[j], t)} yield hash end end end self end
Private Instance Methods
convert_odbc_value(v, t)
click to toggle source
# File lib/sequel/adapters/odbc.rb, line 115 def convert_odbc_value(v, t) # When fetching a result set, the Ruby ODBC driver converts all ODBC # SQL types to an equivalent Ruby type; with the exception of # SQL_TYPE_DATE, SQL_TYPE_TIME and SQL_TYPE_TIMESTAMP. # # The conversions below are consistent with the mappings in # ODBCColumn#mapSqlTypeToGenericType and Column#klass. case v when ::ODBC::TimeStamp db.to_application_timestamp([v.year, v.month, v.day, v.hour, v.minute, v.second, v.fraction]) when ::ODBC::Time Sequel::SQLTime.create(v.hour, v.minute, v.second) when ::ODBC::Date Date.new(v.year, v.month, v.day) else if t == ::ODBC::SQL_BIT v == 1 else v end end end
default_timestamp_format()
click to toggle source
# File lib/sequel/adapters/odbc.rb, line 138 def default_timestamp_format TIMESTAMP_FORMAT end
literal_date(v)
click to toggle source
# File lib/sequel/adapters/odbc.rb, line 142 def literal_date(v) v.strftime(ODBC_DATE_FORMAT) end
literal_false()
click to toggle source
# File lib/sequel/adapters/odbc.rb, line 146 def literal_false BOOL_FALSE end
literal_true()
click to toggle source
# File lib/sequel/adapters/odbc.rb, line 150 def literal_true BOOL_TRUE end