Methods
- B
- C
- E
Instance Public methods
begin_db_transaction()
Link
Begins a transaction.
begin_isolated_db_transaction(isolation)
Link
commit_db_transaction()
Link
Commits a transaction.
exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
Link
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 130 def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil) if use_insert_returning? || pk == false super else result = exec_query(sql, name, binds) unless sequence_name table_ref = extract_table_ref_from_insert_sql(sql) if table_ref pk = primary_key(table_ref) if pk.nil? pk = suppress_composite_primary_key(pk) sequence_name = default_sequence_name(table_ref, pk) end return result unless sequence_name end last_insert_id_result(sequence_name) end end
exec_query(sql, name = "SQL", binds = [], prepare: false)
Link
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 97 def exec_query(sql, name = "SQL", binds = [], prepare: false) execute_and_clear(sql, name, binds, prepare: prepare) do |result| types = {} fields = result.fields fields.each_with_index do |fname, i| ftype = result.ftype i fmod = result.fmod i types[fname] = get_oid_type(ftype, fmod, fname) end ActiveRecord::Result.new(fields, result.values, types) end end
exec_rollback_db_transaction()
Link
Aborts a transaction.
execute(sql, name = nil)
Link
Executes an SQL statement, returning a PG::Result object on success or raising a PG::Error exception otherwise. Note: the PG::Result object is manually memory managed; if you don't need it specifically, you may want consider the exec_query
wrapper.
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 83 def execute(sql, name = nil) if preventing_writes? && write_query?(sql) raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}" end materialize_transactions log(sql, name) do ActiveSupport::Dependencies.interlock.permit_concurrent_loads do @connection.async_exec(sql) end end end
explain(arel, binds = [])
Link