diff options
Diffstat (limited to 'lib/arel/engines/sql/engine.rb')
-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) |