diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-07-20 16:56:15 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-07-20 16:56:15 -0300 |
commit | b326faef0936e5a845d1f6eb9ed2200babfd05f8 (patch) | |
tree | 74ee6ca01aa7dc0a0ab8215796d00c6a87d27d96 /activerecord/lib/active_record | |
parent | 046c22c8c171591fc15594f797b5aac676f3485d (diff) | |
download | rails-b326faef0936e5a845d1f6eb9ed2200babfd05f8.tar.gz rails-b326faef0936e5a845d1f6eb9ed2200babfd05f8.tar.bz2 rails-b326faef0936e5a845d1f6eb9ed2200babfd05f8.zip |
Performance boost for AR#create
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 400884264f..60bd38e74c 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2933,10 +2933,12 @@ module ActiveRecord #:nodoc: self.id = connection.next_sequence_value(self.class.sequence_name) end - new_id = if arel_attributes_values.empty? + attributes_values = arel_attributes_values + + new_id = if attributes_values.empty? arel_table.insert connection.empty_insert_statement_value else - arel_table.insert arel_attributes_values + arel_table.insert attributes_values end self.id ||= new_id @@ -3036,7 +3038,6 @@ module ActiveRecord #:nodoc: # an Arel insert/update method. def arel_attributes_values(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) attrs = {} - connection = self.class.connection attribute_names.each do |name| if (column = column_for_attribute(name)) && (include_primary_key || !column.primary) value = read_attribute(name) |