Class: Sequel::Postgres::Adapter
- Includes:
- AdapterMethods
- Defined in:
- lib/sequel_core/adapters/postgres.rb
Overview
PGconn subclass for connection specific methods used with the pg, postgres, or postgres-pr driver.
Constant Summary
Constants included from AdapterMethods
Sequel::Postgres::AdapterMethods::SELECT_CURRVAL, Sequel::Postgres::AdapterMethods::SELECT_PK, Sequel::Postgres::AdapterMethods::SELECT_PK_AND_CUSTOM_SEQUENCE, Sequel::Postgres::AdapterMethods::SELECT_PK_AND_SERIAL_SEQUENCE
Instance Attribute Summary
Attributes included from AdapterMethods
Instance Method Summary collapse
-
#execute(sql, args = nil) ⇒ Object
Execute the given SQL with this connection.
-
#prepared_statements ⇒ Object
Hash of prepared statements for this connection.
Methods included from AdapterMethods
#last_insert_id, #pkey_and_sequence, #primary_key
Instance Method Details
#execute(sql, args = nil) ⇒ Object
Execute the given SQL with this connection. If a block is given, yield the results, otherwise, return the number of changed rows.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/sequel_core/adapters/postgres.rb', line 119 def execute(sql, args=nil) q = nil begin q = args ? exec(sql, args) : exec(sql) rescue PGError => e raise if status == Adapter::CONNECTION_OK reset q = args ? exec(sql, args) : exec(sql) end begin block_given? ? yield(q) : q.cmd_tuples ensure q.clear end end |
#prepared_statements ⇒ Object
Hash of prepared statements for this connection. Keys are string names of the server side prepared statement, and values are SQL strings.
139 140 141 |
# File 'lib/sequel_core/adapters/postgres.rb', line 139 def prepared_statements @prepared_statements ||= {} end |