Sha256: 57d3579c56fc2d6d1c790f3b35c7ece2140b4322c6d4c12ec380f30e197ca5b1

Contents?: true

Size: 727 Bytes

Versions: 19

Compression:

Stored size: 727 Bytes

Contents

# This class controls the result for the MySQL2 driver.
class Baza::Driver::Mysql2::Result < Baza::ResultBase
  # Constructor. This should not be called manually.
  def initialize(driver, result)
    @result = result
    @type_translation = driver.db.opts[:type_translation]
  end

  # Returns a single result.
  def fetch
    return to_enum.next
  rescue StopIteration
    return false
  end

  # Loops over every single result yielding it.
  def each
    return unless @result

    @result.each(as: :hash, symbolize_keys: true) do |row|
      next unless row # This sometimes happens when streaming results...
      row = Hash[row.map { |k, v| [k, v.to_s] }] if @type_translation == :string
      yield row
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
baza-0.0.39 lib/baza/driver/mysql2/result.rb
baza-0.0.38 lib/baza/driver/mysql2/result.rb
baza-0.0.37 lib/baza/driver/mysql2/result.rb
baza-0.0.36 lib/baza/driver/mysql2/result.rb
baza-0.0.35 lib/baza/driver/mysql2/result.rb
baza-0.0.34 lib/baza/driver/mysql2/result.rb
baza-0.0.33 lib/baza/driver/mysql2/result.rb
baza-0.0.32 lib/baza/driver/mysql2/result.rb
baza-0.0.31 lib/baza/driver/mysql2/result.rb
baza-0.0.30 lib/baza/driver/mysql2/result.rb
baza-0.0.29 lib/baza/driver/mysql2/result.rb
baza-0.0.28 lib/baza/driver/mysql2/result.rb
baza-0.0.27 lib/baza/driver/mysql2/result.rb
baza-0.0.26 lib/baza/driver/mysql2/result.rb
baza-0.0.25 lib/baza/driver/mysql2/result.rb
baza-0.0.24 lib/baza/driver/mysql2/result.rb
baza-0.0.23 lib/baza/driver/mysql2/result.rb
baza-0.0.22 lib/baza/driver/mysql2/result.rb
baza-0.0.21 lib/baza/driver/mysql2/result.rb