Module: Sequel::DataObjects::Postgres::DatabaseMethods

Includes:
Postgres::DatabaseMethods
Defined in:
lib/sequel/lib/sequel/adapters/do/postgres.rb

Overview

Methods to add to Database instances that access PostgreSQL via DataObjects.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(db) ⇒ Object

Add the primary_keys and primary_key_sequences instance variables, so we can get the correct return values for inserted rows.


52
53
54
55
56
57
# File 'lib/sequel/lib/sequel/adapters/do/postgres.rb', line 52

def self.extended(db)
  db.instance_eval do
    @primary_keys = {}
    @primary_key_sequences = {}
  end
end

Instance Method Details

#dataset(opts = nil) ⇒ Object

Return instance of Sequel::DataObjects::Postgres::Dataset with the given opts.


60
61
62
# File 'lib/sequel/lib/sequel/adapters/do/postgres.rb', line 60

def dataset(opts=nil)
  Sequel::DataObjects::Postgres::Dataset.new(self, opts)
end

#execute_insert(sql, opts = {}) ⇒ Object

Run the INSERT sql on the database and return the primary key for the record.


66
67
68
69
70
71
72
# File 'lib/sequel/lib/sequel/adapters/do/postgres.rb', line 66

def execute_insert(sql, opts={})
  log_info(sql)
  synchronize(opts[:server]) do |conn|
    conn.create_command(sql).execute_non_query
    insert_result(conn, opts[:table], opts[:values])
  end
end