Module: ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb |
Constant Summary
-
IDLE_TRANSACTION_STATUSES =
private
# File 'activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb', line 124[PG::PQTRANS_IDLE, PG::PQTRANS_INTRANS, PG::PQTRANS_INERROR]
Instance Method Summary
- #build_explain_clause(options = [])
- #explain(arel, binds = [], options = [])
- #high_precision_current_timestamp
-
#set_constraints(deferred, *constraints)
Set when constraints will be checked for the current transaction.
Instance Method Details
#build_explain_clause(options = [])
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb', line 96
def build_explain_clause( = []) return "EXPLAIN" if .empty? "EXPLAIN (#{ .join(", ").upcase})" end
#explain(arel, binds = [], options = [])
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb', line 7
def explain(arel, binds = [], = []) sql = build_explain_clause( ) + " " + to_sql(arel, binds) result = internal_exec_query(sql, "EXPLAIN", binds) PostgreSQL::ExplainPrettyPrinter.new.pp(result) end
#high_precision_current_timestamp
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb', line 92
def HIGH_PRECISION_CURRENT_TIMESTAMP end
#set_constraints(deferred, *constraints)
Set when constraints will be checked for the current transaction.
Not passing any specific constraint names will set the value for all deferrable constraints.
deferred
-
Valid values are
:deferred
or:immediate
.
See www.postgresql.org/docs/current/sql-set-constraints.html
# File 'activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb', line 110
def set_constraints(deferred, *constraints) unless %i[deferred immediate].include?(deferred) raise ArgumentError, "deferred must be :deferred or :immediate" end constraints = if constraints.empty? "ALL" else constraints.map { |c| quote_table_name(c) }.join(", ") end execute("SET CONSTRAINTS #{constraints} #{deferred.to_s.upcase}") end