Skip to content

Commit

Permalink
pass primary_key value to AR adapter insert method (necessary for Ora…
Browse files Browse the repository at this point in the history
…cle adapter)
  • Loading branch information
rsim committed Mar 1, 2010
1 parent 07dcfd4 commit 5ab0598
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/arel/engines/sql/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5ab0598

Please sign in to comment.