Method: ActiveRecord::PGExtensions::PostgreSQLAdapter#set_constraints
- Defined in:
- lib/active_record/pg_extensions/postgresql_adapter.rb
permalink #set_constraints(deferred, *constraints) ⇒ Object
set constraint check timing for the current transaction see www.postgresql.org/docs/current/sql-set-constraints.html
11 12 13 14 15 16 17 18 |
# File 'lib/active_record/pg_extensions/postgresql_adapter.rb', line 11 def set_constraints(deferred, *constraints) raise ArgumentError, "deferred must be :deferred or :immediate" unless %i[deferred immediate].include?(deferred.to_sym) constraints = constraints.map { |c| quote_table_name(c) }.join(", ") constraints = "ALL" if constraints.empty? execute("SET CONSTRAINTS #{constraints} #{deferred.to_s.upcase}") end |