Class: Baza::JdbcResult

Inherits:
ResultBase show all
Defined in:
lib/baza/jdbc_result.rb

Overview

This class controls the result for the Java-MySQL-driver.

Constant Summary collapse

INT_TYPES =
{-6 => true, -5 => true, 4 => true, 5 => true}.freeze
FLOAT_TYPES =
{2 => true, 3 => true, 7 => true, 8 => true}.freeze
TIME_TYPES =
{93 => true}.freeze
DATE_TYPES =
{91 => true}.freeze
STRING_TYPES =
{-1 => true, 1 => true, 12 => true}.freeze
NIL_TYPES =
{0 => true}.freeze

Instance Method Summary collapse

Methods inherited from ResultBase

#to_a, #to_a_enum, #to_enum

Constructor Details

#initialize(driver, stmt, result_set, preload_results) ⇒ JdbcResult

Constructor. This should not be called manually.



11
12
13
14
15
16
17
18
# File 'lib/baza/jdbc_result.rb', line 11

def initialize(driver, stmt, result_set, preload_results)
  @result_set = result_set
  @stmt = stmt
  @type_translation = driver.db.opts[:type_translation]
  @rows = []
  @index = -1
  read_results if preload_results
end

Instance Method Details

#eachObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/baza/jdbc_result.rb', line 29

def each
  loop do
    data = fetch

    if data
      yield data
    else
      break
    end
  end
end

#fetchObject



20
21
22
23
24
25
26
27
# File 'lib/baza/jdbc_result.rb', line 20

def fetch
  if @read_results
    return false if @rows.empty?
    @rows.shift
  else
    read_row
  end
end