diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-22 09:18:01 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-22 09:18:01 -0700 |
commit | 15d3cc21f41af4b3caaae4f3586481effa77058f (patch) | |
tree | a013d8934c7df44bbadcb349708270fe3197503e /activerecord/lib/active_record/persistence.rb | |
parent | 3378d77b044306d6e92f188932d435483af569e3 (diff) | |
download | rails-15d3cc21f41af4b3caaae4f3586481effa77058f.tar.gz rails-15d3cc21f41af4b3caaae4f3586481effa77058f.tar.bz2 rails-15d3cc21f41af4b3caaae4f3586481effa77058f.zip |
pushing id insertion and prefetch primary keys down to Relation#insert
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index df7b22080c..17a64b6e86 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -270,17 +270,9 @@ module ActiveRecord # Creates a record with values matching those of the instance attributes # and returns its id. def create - if id.nil? && connection.prefetch_primary_key?(self.class.table_name) - self.id = connection.next_sequence_value(self.class.sequence_name) - end - attributes_values = arel_attributes_values(!id.nil?) - new_id = if attributes_values.empty? - self.class.unscoped.insert connection.empty_insert_statement_value - else - self.class.unscoped.insert attributes_values - end + new_id = self.class.unscoped.insert attributes_values self.id ||= new_id |