Class Sequel::ODBC::Dataset
In: lib/sequel_core/adapters/odbc.rb
Parent: Sequel::Dataset

Methods

Constants

BOOL_TRUE = '1'.freeze
BOOL_FALSE = '0'.freeze
ODBC_TIMESTAMP_FORMAT = "{ts '%Y-%m-%d %H:%M:%S'}".freeze
ODBC_TIMESTAMP_AFTER_SECONDS = ODBC_TIMESTAMP_FORMAT.index( '%S' ).succ - ODBC_TIMESTAMP_FORMAT.length
ODBC_DATE_FORMAT = "{d '%Y-%m-%d'}".freeze
UNTITLED_COLUMN = 'untitled_%d'.freeze

Public Instance methods

[Source]

     # File lib/sequel_core/adapters/odbc.rb, line 124
124:       def fetch_rows(sql, &block)
125:         execute(sql) do |s|
126:           begin
127:             untitled_count = 0
128:             @columns = s.columns(true).map do |c|
129:               if (n = c.name).empty?
130:                 n = UNTITLED_COLUMN % (untitled_count += 1)
131:               end
132:               output_identifier(n)
133:             end
134:             rows = s.fetch_all
135:             rows.each {|row| yield hash_row(row)} if rows
136:           ensure
137:             s.drop unless s.nil? rescue nil
138:           end
139:         end
140:         self
141:       end

[Source]

     # File lib/sequel_core/adapters/odbc.rb, line 104
104:       def literal(v)
105:         case v
106:         when true
107:           BOOL_TRUE
108:         when false
109:           BOOL_FALSE
110:         when Time, DateTime
111:           formatted = v.strftime(ODBC_TIMESTAMP_FORMAT)
112:           usec = (Time === v ? v.usec : (v.sec_fraction * 86400000000))
113:           formatted.insert(ODBC_TIMESTAMP_AFTER_SECONDS, ".#{(usec.to_f/1000).round}") if usec >= 1000
114:           formatted
115:         when Date
116:           v.strftime(ODBC_DATE_FORMAT)
117:         else
118:           super
119:         end
120:       end

[Validate]