модуль ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements
Открытые методы экземпляра
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 134
def build_explain_clause(options = [])
return "EXPLAIN" if options.empty?
"EXPLAIN (#{options.join(", ").upcase})"
end # File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 7 def explain(arel, binds = [], options = []) sql = build_explain_clause(options) + " " + to_sql(arel, binds) result = internal_exec_query(sql, "EXPLAIN", binds) PostgreSQL::ExplainPrettyPrinter.new.pp(result) end
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 130 def high_precision_current_timestamp HIGH_PRECISION_CURRENT_TIMESTAMP end
raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true) Показать исходный код
# File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 53
def raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true)
log(sql, name, async: async) do |notification_payload|
with_raw_connection(allow_retry: allow_retry, materialize_transactions: materialize_transactions) do |conn|
result = conn.async_exec(sql)
verified!
handle_warnings(result)
notification_payload[:row_count] = result.count
result
end
end
end # File activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb, line 148
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 Устанавливает время проверки ограничений в текущей транзакции.
Если не указаны конкретные имена ограничений, значение устанавливается для всех откладываемых ограничений.
-
deferred -
Допустимые значения —
:deferredили:immediate.
См. www.postgresql.org/docs/current/sql-set-constraints.html
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.