Class: RDBI::Driver::JDBC::Cursor

Inherits:
Cursor
  • Object
show all
Defined in:
lib/caruby/rdbi/driver/jdbc.rb

Instance Method Summary collapse

Constructor Details

#initialize(handle) ⇒ Cursor

TODO: update this to use real calls, not array to get this working, we’ll just build the array for now.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 139

def initialize(handle)
  super handle

  @index = 0
  @rs = []

  return if handle.nil?

  rs       = handle.getResultSet
   = rs.

  while rs.next
    data = []
    (1...getColumnCount).each do |n|
      data << parse_column(rs, n, )
    end
    @rs << data
  end
end

Instance Method Details

#[](index) ⇒ Object



195
196
197
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 195

def [](index)
  @rs[index]
end

#affected_countObject



170
171
172
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 170

def affected_count
  0
end

#allObject



186
187
188
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 186

def all
  @rs
end

#coerce_to_arrayObject



219
220
221
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 219

def coerce_to_array
  @rs
end

#empty?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 203

def empty?
  @rs.empty?
end

#fetch(count = 1) ⇒ Object



190
191
192
193
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 190

def fetch(count = 1)
  return [] if last_row?
  @rs[@index, count]
end

#finishObject



215
216
217
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 215

def finish
  @handle.close
end

#firstObject



174
175
176
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 174

def first
  @rs.first
end

#lastObject



178
179
180
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 178

def last
  @rs.last
end

#last_row?Boolean

Returns:

  • (Boolean)


199
200
201
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 199

def last_row?
  @index == @rs.size
end

#next_rowObject



159
160
161
162
163
164
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 159

def next_row
  return nil if last_row?
  val = @rs[@index]
  @index += 1
  val
end

#restObject



182
183
184
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 182

def rest
  @rs[@index..-1]
end

#result_countObject



166
167
168
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 166

def result_count
  @rs.size
end

#rewindObject



207
208
209
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 207

def rewind
  @index = 0
end

#sizeObject



211
212
213
# File 'lib/caruby/rdbi/driver/jdbc.rb', line 211

def size
  @rs.length
end