Hi guys, this is code from ActiveRecord::Persistance:
def _create_record(attribute_names = self.attribute_names) attributes_values = arel_attributes_with_values_for_create(attribute_names) new_id = self.class.unscoped.insert attributes_values self.id ||= new_id if self.class.primary_key @new_record = false id end I'm curious about the rational behind line no. 5. Why we set `self.id` to value returned from db only if it was previously empty? I couldn't find any test nor some discussion. Also the code dates back to 2011. I work with some legacy db where primary key is string which is modified in some database trigger. Because the `self.id` is set before save it isn't assigned to proper value returned from db after trigger modification. I can't think of any problem if we always assign id to value returned from database. I would love to create PR if it's ok thanks! -- Sledujte náš blog.uol.cz, facebook.com/uol.cz, gplus.to/uolcz <http://facebook.com/uol.cz> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.