diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-14 15:58:43 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-14 16:14:47 +0000 |
commit | 18bf30982bb2ec013dc65a7e7e65ff45fcd4d73b (patch) | |
tree | 489c68937aa9e276181cb6336d71cb0c810f88c0 /activerecord/lib/active_record | |
parent | 7b0edbb9f2548b9e88979c737152079c41ed0ab7 (diff) | |
download | rails-18bf30982bb2ec013dc65a7e7e65ff45fcd4d73b.tar.gz rails-18bf30982bb2ec013dc65a7e7e65ff45fcd4d73b.tar.bz2 rails-18bf30982bb2ec013dc65a7e7e65ff45fcd4d73b.zip |
Cache column defaults on model. ~30% on Model.new due to avoiding repeatedly fetching connection.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index ba75dc6d09..9215a68cfc 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -782,7 +782,7 @@ module ActiveRecord #:nodoc: # Returns a hash where the keys are column names and the values are # default values when instantiating the AR object for this table. def column_defaults - connection.schema_cache.column_defaults[table_name] + @column_defaults ||= connection.schema_cache.column_defaults[table_name] end # Returns an array of column names as strings. @@ -841,7 +841,7 @@ module ActiveRecord #:nodoc: undefine_attribute_methods connection.schema_cache.clear_table_cache!(table_name) if table_exists? - @column_names = @content_columns = @dynamic_methods_hash = @inheritance_column = nil + @column_names = @content_columns = @column_defaults = @dynamic_methods_hash = @inheritance_column = nil @arel_engine = @relation = nil end |