Skip to content

Commit

Permalink
Merge pull request rails#1929 from sobrinho/master
Browse files Browse the repository at this point in the history
Create a test case for disable_referential_integrity
  • Loading branch information
spastorino committed Jul 11, 2011
2 parents 8f2e321 + 5399471 commit 539d684
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions activerecord/test/cases/adapter_test.rb
Expand Up @@ -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

0 comments on commit 539d684

Please sign in to comment.