Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed test_foreign_key_violations_are_translated_to_specific_exceptio…

…n to work with Oracle
  • Loading branch information...
commit 53be10c5e6939c9093c4ae863fd380a6dbf1e50e 1 parent 44a7ef8
@rsim rsim authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 activerecord/test/cases/adapter_test.rb
View
8 activerecord/test/cases/adapter_test.rb
@@ -132,7 +132,13 @@ def test_uniqueness_violations_are_translated_to_specific_exception
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
Please sign in to comment.
Something went wrong with that request. Please try again.