Permalink
Browse files

fixed retrieval of primary key value in Ralation#insert method

previously primary key value was always assigned nil which caused Oracle enhanced adapter failing tests
  • Loading branch information...
1 parent d9c8c47 commit 2b795050de72c6d68aba7513510f74ddc8959ee7 @rsim rsim committed with tenderlove Dec 23, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/relation.rb
@@ -31,7 +31,7 @@ def insert(values)
im = arel.compile_insert values
im.into @table
primary_key_name = @klass.primary_key
- primary_key_value = Hash === values ? values[primary_key_name] : nil
+ primary_key_value = primary_key_name && Hash === values ? values[primary_key] : nil
@klass.connection.insert(
im.to_sql,

3 comments on commit 2b79505

Contributor

exviva commented on 2b79505 Dec 23, 2010

Shouldn't it be values[primary_key_name] instead of values[primary_key] in line 34?

Contributor

rsim replied Dec 27, 2010

values hash has Arel::Attribute objects as keys and not attribute names therefore primary_key (which returns Arel::Attribute for primary key) should be used instead of primary_key_name which is String.

Contributor

exviva replied Jan 5, 2011

Thanks

Please sign in to comment.