diff options
author | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2009-03-23 00:08:37 +0200 |
---|---|---|
committer | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2009-08-06 23:40:59 +0300 |
commit | c3e1ef0b4051c515fa2e3f49ea47309c79a89aee (patch) | |
tree | d4955d2eb20663f23a3fddf4bf5f1c70b43ad039 /activerecord | |
parent | a12358b3a5e69f41079595d5c92677b66ae6e642 (diff) | |
download | rails-c3e1ef0b4051c515fa2e3f49ea47309c79a89aee.tar.gz rails-c3e1ef0b4051c515fa2e3f49ea47309c79a89aee.tar.bz2 rails-c3e1ef0b4051c515fa2e3f49ea47309c79a89aee.zip |
Oracle needs sequence value for primary key in INSERT statement
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/database_statements_test.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/test/cases/database_statements_test.rb b/activerecord/test/cases/database_statements_test.rb index 6274d5250f..c689e97d83 100644 --- a/activerecord/test/cases/database_statements_test.rb +++ b/activerecord/test/cases/database_statements_test.rb @@ -6,7 +6,14 @@ class DatabaseStatementsTest < ActiveRecord::TestCase end def test_insert_should_return_the_inserted_id - id = @connection.insert("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)") + # Oracle adapter uses prefetched primary key values from sequence and passes them to connection adapter insert method + if current_adapter?(:OracleAdapter) + sequence_name = "accounts_seq" + id_value = @connection.next_sequence_value(sequence_name) + id = @connection.insert("INSERT INTO accounts (id, firm_id,credit_limit) VALUES (accounts_seq.nextval,42,5000)", nil, :id, id_value, sequence_name) + else + id = @connection.insert("INSERT INTO accounts (firm_id,credit_limit) VALUES (42,5000)") + end assert_not_nil id end end |