class Sequel::Fdbsql::Dataset
Dataset class for the FoundationDB SQL Layer that uses the pg driver.
Public Instance Methods
call(type, bind_vars=OPTS, *values, &block)
click to toggle source
Execute the given type of statement with the hash of values.
# File lib/sequel/adapters/fdbsql.rb, line 148 def call(type, bind_vars=OPTS, *values, &block) ps = to_prepared_statement(type, values) ps.extend(BindArgumentMethods) ps.call(bind_vars, &block) end
fetch_rows(sql) { |h| ... }
click to toggle source
Yield all rows returned by executing the given SQL and converting the types.
# File lib/sequel/adapters/fdbsql.rb, line 156 def fetch_rows(sql) execute(sql) do |res| columns = set_columns(res) yield_hash_rows(res, columns) {|h| yield h} end end
prepare(type, name=nil, *values)
click to toggle source
Prepare the given type of statement with the given name, and store it in the database to be called later.
# File lib/sequel/adapters/fdbsql.rb, line 165 def prepare(type, name=nil, *values) ps = to_prepared_statement(type, values) ps.extend(PreparedStatementMethods) if name ps.prepared_statement_name = name db.set_prepared_statement(name, ps) end ps end
Private Instance Methods
set_columns(res)
click to toggle source
# File lib/sequel/adapters/fdbsql.rb, line 177 def set_columns(res) cols = [] procs = db.conversion_procs res.nfields.times do |fieldnum| cols << [fieldnum, procs[res.ftype(fieldnum)], output_identifier(res.fname(fieldnum))] end @columns = cols.map{|c| c[2]} cols end
yield_hash_rows(res, cols) { |converted_rec| ... }
click to toggle source
For each row in the result set, yield a hash with column name symbol keys and typecasted values.
# File lib/sequel/adapters/fdbsql.rb, line 189 def yield_hash_rows(res, cols) res.ntuples.times do |recnum| converted_rec = {} cols.each do |fieldnum, type_proc, fieldsym| value = res.getvalue(recnum, fieldnum) converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value end yield converted_rec end end