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.

Methods

Included Modules

Sequel::Postgres::DatasetMethods

Classes and Modules

Module Sequel::Postgres::Dataset::ArgumentMapper
Module Sequel::Postgres::Dataset::BindArgumentMethods
Module Sequel::Postgres::Dataset::PreparedStatementMethods

Constants

PREPARED_ARG_PLACEHOLDER = LiteralString.new('$').freeze

Public Instance methods

Execute the given type of statement with the hash of values.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 410
410:         def call(type, hash, values=nil, &block)
411:           ps = to_prepared_statement(type, values)
412:           ps.extend(BindArgumentMethods)
413:           ps.call(hash, &block)
414:         end

Yield all rows returned by executing the given SQL and converting the types.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 307
307:       def fetch_rows(sql)
308:         cols = []
309:         execute(sql) do |res|
310:           res.nfields.times do |fieldnum|
311:             cols << [fieldnum, PG_TYPES[res.ftype(fieldnum)], output_identifier(res.fname(fieldnum))]
312:           end
313:           @columns = cols.map{|c| c.at(2)}
314:           res.ntuples.times do |recnum|
315:             converted_rec = {}
316:             cols.each do |fieldnum, type_proc, fieldsym|
317:               value = res.getvalue(recnum, fieldnum)
318:               converted_rec[fieldsym] = (value && type_proc) ? type_proc.call(value) : value
319:             end
320:             yield converted_rec
321:           end
322:         end
323:       end

Prepare the given type of statement with the given name, and store it in the database to be called later.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 418
418:         def prepare(type, name=nil, values=nil)
419:           ps = to_prepared_statement(type, values)
420:           ps.extend(PreparedStatementMethods)
421:           if name
422:             ps.prepared_statement_name = name
423:             db.prepared_statements[name] = ps
424:           end
425:           ps
426:         end

PostgreSQL uses $N for placeholders instead of ?, so use a $ as the placeholder.

[Source]

     # File lib/sequel/adapters/postgres.rb, line 432
432:         def prepared_arg_placeholder
433:           PREPARED_ARG_PLACEHOLDER
434:         end

[Validate]