Browse files

pass primary_key value to AR adapter insert method (necessary for Ora…

…cle adapter)
  • Loading branch information...
1 parent 07dcfd4 commit 5ab0598b091dbe5679f96b1f7a097178c3caaf3b @rsim rsim committed Mar 1, 2010
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/arel/engines/sql/engine.rb
View
8 lib/arel/engines/sql/engine.rb
@@ -26,7 +26,13 @@ def method_missing(method, *args, &block)
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)

0 comments on commit 5ab0598

Please sign in to comment.