diff options
author | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2009-07-23 20:02:04 +0300 |
---|---|---|
committer | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2009-08-06 23:41:00 +0300 |
commit | 53be10c5e6939c9093c4ae863fd380a6dbf1e50e (patch) | |
tree | 8ffd58429ff0f7e6e437d4d2ab23ee0ded486682 /activerecord/test | |
parent | 44a7ef85eba5491aaef5a890ef2b44b111888d35 (diff) | |
download | rails-53be10c5e6939c9093c4ae863fd380a6dbf1e50e.tar.gz rails-53be10c5e6939c9093c4ae863fd380a6dbf1e50e.tar.bz2 rails-53be10c5e6939c9093c4ae863fd380a6dbf1e50e.zip |
fixed test_foreign_key_violations_are_translated_to_specific_exception to work with Oracle
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapter_test.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 65c5fc2fe9..88136597e3 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -132,7 +132,13 @@ class AdapterTest < ActiveRecord::TestCase def test_foreign_key_violations_are_translated_to_specific_exception unless @connection.adapter_name == 'SQLite' assert_raises(ActiveRecord::InvalidForeignKey) do - @connection.execute "INSERT INTO fk_test_has_fk (fk_id) VALUES (0)" + # 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 |