class Sequel::Swift::Dataset

Public Instance Methods

fetch_rows(sql) { |h| ... } click to toggle source

Set the columns and yield the hashes to the block.

# File lib/sequel/adapters/swift.rb, line 132
def fetch_rows(sql)
  execute(sql) do |res|
    col_map = {}
    @columns = res.fields.map do |c|
      col_map[c] = output_identifier(c)
    end
    tz = db.timezone if Sequel.application_timezone
    res.each do |r|
      h = {}
      r.each do |k, v|
        h[col_map[k]] = case v
        when StringIO
          SQL::Blob.new(v.read)
        when DateTime
          tz ? Sequel.database_to_application_timestamp(Sequel.send(:convert_input_datetime_no_offset, v, tz)) : v
        else
          v
        end
      end
      yield h
    end
  end
  self
end