instance method
set_constraints
Ruby on Rails 7.2.3
Since v7.2.3Signature
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
:deferredor:immediate.
See www.postgresql.org/docs/current/sql-set-constraints.html
Parameters
-
deferredreq -
constraintsrest
Source
# 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
Defined in activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb line 148
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements