mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #8548 from garysweaver/postgresql_fallback_to_disable_user_triggers
fix #5523: postgresql adapter to disable user triggers in disable_referential_integrity
This commit is contained in:
commit
e4003adff9
2 changed files with 17 additions and 4 deletions
|
@ -1,5 +1,10 @@
|
||||||
## Rails 4.0.0 (unreleased) ##
|
## Rails 4.0.0 (unreleased) ##
|
||||||
|
|
||||||
|
* Add ability for postgresql adapter to disable user triggers in disable_referential_integrity.
|
||||||
|
Fix #5523
|
||||||
|
|
||||||
|
*Gary S. Weaver*
|
||||||
|
|
||||||
* Added support for `validates_uniqueness_of` in PostgreSQL array columns.
|
* Added support for `validates_uniqueness_of` in PostgreSQL array columns.
|
||||||
Fixes #8075.
|
Fixes #8075.
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,21 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def disable_referential_integrity #:nodoc:
|
def disable_referential_integrity #:nodoc:
|
||||||
if supports_disable_referential_integrity? then
|
if supports_disable_referential_integrity?
|
||||||
|
begin
|
||||||
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
|
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER ALL" }.join(";"))
|
||||||
|
rescue
|
||||||
|
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} DISABLE TRIGGER USER" }.join(";"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
if supports_disable_referential_integrity? then
|
if supports_disable_referential_integrity?
|
||||||
|
begin
|
||||||
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
|
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER ALL" }.join(";"))
|
||||||
|
rescue
|
||||||
|
execute(tables.collect { |name| "ALTER TABLE #{quote_table_name(name)} ENABLE TRIGGER USER" }.join(";"))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue