diff options
author | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-03-01 16:23:09 +0200 |
---|---|---|
committer | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-03-01 16:23:09 +0200 |
commit | 5ab0598b091dbe5679f96b1f7a097178c3caaf3b (patch) | |
tree | eb9d883fa96f5dea9ac046b99269d0c5a0970186 | |
parent | 07dcfd4ea7c052063e912ab479f64da78848a66e (diff) | |
download | rails-5ab0598b091dbe5679f96b1f7a097178c3caaf3b.tar.gz rails-5ab0598b091dbe5679f96b1f7a097178c3caaf3b.tar.bz2 rails-5ab0598b091dbe5679f96b1f7a097178c3caaf3b.zip |
pass primary_key value to AR adapter insert method (necessary for Oracle adapter)
-rw-r--r-- | lib/arel/engines/sql/engine.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/arel/engines/sql/engine.rb b/lib/arel/engines/sql/engine.rb index 054de21a70..6087a26816 100644 --- a/lib/arel/engines/sql/engine.rb +++ b/lib/arel/engines/sql/engine.rb @@ -26,7 +26,13 @@ module Arel module CRUD def create(relation) - connection.insert(relation.to_sql(false), nil, relation.primary_key) + primary_key_value = nil + if primary_key = relation.primary_key + if primary_key_attribute_and_value = relation.record.detect{|k, v| k.name.to_s == primary_key.to_s} + primary_key_value = primary_key_attribute_and_value[1].value + end + end + connection.insert(relation.to_sql(false), nil, primary_key, primary_key_value) end def read(relation) |