Class: Sequel::JDBC::HXTT::Dataset

Inherits:
JDBC::Dataset
  • Object
show all
Defined in:
lib/sequel/adapters/jdbc/hxtt.rb

Overview

Dataset class for MS Access datasets accessed via JDBC.

Constant Summary collapse

BOOL_TRUE =
'TRUE'.freeze
BOOL_FALSE =
'FALSE'.freeze
SELECT_CLAUSE_METHODS =
Dataset.clause_methods(:select, %w'limit columns from where')

Instance Method Summary collapse

Instance Method Details

#literal_falseObject



126
127
128
# File 'lib/sequel/adapters/jdbc/hxtt.rb', line 126

def literal_false
  BOOL_FALSE
end

#literal_trueObject



130
131
132
# File 'lib/sequel/adapters/jdbc/hxtt.rb', line 130

def literal_true
  BOOL_TRUE
end

#process_result_set(result) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/sequel/adapters/jdbc/hxtt.rb', line 146

def process_result_set(result)
  # get column names
  meta = result.
  cols = []
  i = 0
  meta.getColumnCount.times{cols << [output_identifier(meta.getColumnLabel(i+=1)), i]}
  @columns = cols.map{|c| c.at(0)}
  row = {}
  blk = if @convert_types
    lambda{ |n, i|
      # XXX: temporary fix until i can figure out how to get the access column default Date() not to throw an error
      begin
        row[n] = convert_type(result.getObject(i))
      rescue Exception => e
        if e.message == 'java.sql.SQLException: Failed to get a string value from com.hxtt.d.d: DATE()'
          row[n] = 'DATE()'
        else
          raise
        end
      end
    }
  else
    lambda{|n, i| row[n] = result.getObject(i)}
  end
  # get rows
  while result.next
    row = {}
    cols.each(&blk)
    yield row
  end
end

#quoted_identifier(name) ⇒ Object

access uses [] to quote identifiers



122
123
124
# File 'lib/sequel/adapters/jdbc/hxtt.rb', line 122

def quoted_identifier(name)
  "[#{name}]"
end

#select_clause_methodsObject



134
135
136
# File 'lib/sequel/adapters/jdbc/hxtt.rb', line 134

def select_clause_methods
  SELECT_CLAUSE_METHODS
end

#select_limit_sql(sql) ⇒ Object



138
139
140
# File 'lib/sequel/adapters/jdbc/hxtt.rb', line 138

def select_limit_sql(sql)
  sql << " TOP #{@opts[:limit]}" if @opts[:limit]
end

#supports_is_true?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/sequel/adapters/jdbc/hxtt.rb', line 142

def supports_is_true?
  false
end