Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Create a test case for disable_referential_integrity #1921

Closed
wants to merge 3 commits into from

2 participants

@sobrinho

No description provided.

sobrinho added some commits
@sobrinho sobrinho Use "SET CONSTRAINTS ALL DEFERRED" and "SET CONSTRAINTS ALL IMMEDIATE…
…" to disable foreign keys on postgresql adapter
7213884
@sobrinho sobrinho Create a test case for disable_referential_integrity 5ccc412
@sobrinho sobrinho Revert "Use "SET CONSTRAINTS ALL DEFERRED" and "SET CONSTRAINTS ALL I…
…MMEDIATE" to disable foreign keys on postgresql adapter"

This reverts commit 8c98dd129afb649fcdc9e4d6a4590a1457a096f5.
5aed7cc
@dmathieu
Collaborator

Could you rebase your pull request to have only the non-reverted commit ?

@sobrinho
@sobrinho sobrinho closed this
@sobrinho

Opening another pull request without reverted commits.

@sobrinho
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 30, 2011
  1. @sobrinho

    Use "SET CONSTRAINTS ALL DEFERRED" and "SET CONSTRAINTS ALL IMMEDIATE…

    sobrinho authored
    …" to disable foreign keys on postgresql adapter
  2. @sobrinho
  3. @sobrinho

    Revert "Use "SET CONSTRAINTS ALL DEFERRED" and "SET CONSTRAINTS ALL I…

    sobrinho authored
    …MMEDIATE" to disable foreign keys on postgresql adapter"
    
    This reverts commit 8c98dd129afb649fcdc9e4d6a4590a1457a096f5.
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 0 deletions.
  1. +14 −0 activerecord/test/cases/adapter_test.rb
View
14 activerecord/test/cases/adapter_test.rb
@@ -146,4 +146,18 @@ def test_foreign_key_violations_are_translated_to_specific_exception
end
end
end
+
+ def test_disable_referential_integrity
+ assert_nothing_raised do
+ @connection.disable_referential_integrity do
+ # Oracle adapter uses prefetched primary key values from sequence and passes them to connection adapter insert method
+ if @connection.prefetch_primary_key?
+ id_value = @connection.next_sequence_value(@connection.default_sequence_name("fk_test_has_fk", "id"))
+ @connection.execute "INSERT INTO fk_test_has_fk (id, fk_id) VALUES (#{id_value},0)"
+ else
+ @connection.execute "INSERT INTO fk_test_has_fk (fk_id) VALUES (0)"
+ end
+ end
+ end
+ end
end
Something went wrong with that request. Please try again.