diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-12-29 01:22:12 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-12-29 01:22:43 -0200 |
commit | bf22b287a4720cd4e5fc4206262a09ebf490609a (patch) | |
tree | 03a74129c8d507cf6589315dc141742eacec24f0 /activerecord | |
parent | 27d0d4fffdb62d221e124b67b7ee3de6bfa1893b (diff) | |
download | rails-bf22b287a4720cd4e5fc4206262a09ebf490609a.tar.gz rails-bf22b287a4720cd4e5fc4206262a09ebf490609a.tar.bz2 rails-bf22b287a4720cd4e5fc4206262a09ebf490609a.zip |
Do not use primary key on insertion when it's nil
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 1fc9472231..b05957981d 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -258,11 +258,11 @@ module ActiveRecord # Creates a record with values matching those of the instance attributes # and returns its id. def create - if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name) + 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 + attributes_values = arel_attributes_values(!id.nil?) new_id = if attributes_values.empty? self.class.unscoped.insert connection.empty_insert_statement_value |