| Class | Sequel::Postgres::Dataset |
| In: |
lib/sequel/adapters/postgres.rb
|
| Parent: | Sequel::Dataset |
Dataset class for PostgreSQL datasets that use the pg, postgres, or postgres-pr driver.
| PREPARED_ARG_PLACEHOLDER | = | LiteralString.new('$').freeze |
Execute the given type of statement with the hash of values.
# File lib/sequel/adapters/postgres.rb, line 414
414: def call(type, hash, values=nil, &block)
415: ps = to_prepared_statement(type, values)
416: ps.extend(BindArgumentMethods)
417: ps.call(hash, &block)
418: end
Yield all rows returned by executing the given SQL and converting the types.
# File lib/sequel/adapters/postgres.rb, line 311
311: def fetch_rows(sql)
312: cols = []
313: execute(sql) do |res|
314: res.nfields.times do |fieldnum|
315: cols << [fieldnum, PG_TYPES[res.ftype(fieldnum)], output_identifier(res.fname(fieldnum))]
316: end
317: @columns = cols.map{|c| c.at(2)}
318: res.ntuples.times do |recnum|
319: converted_rec = {}
320: cols.each do |fieldnum, type_proc, fieldsym|
321: value = res.getvalue(recnum, fieldnum)
322: converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value
323: end
324: yield converted_rec
325: end
326: end
327: end
Prepare the given type of statement with the given name, and store it in the database to be called later.
# File lib/sequel/adapters/postgres.rb, line 422
422: def prepare(type, name=nil, values=nil)
423: ps = to_prepared_statement(type, values)
424: ps.extend(PreparedStatementMethods)
425: if name
426: ps.prepared_statement_name = name
427: db.prepared_statements[name] = ps
428: end
429: ps
430: end