Ticket #9046: cache_column_names.patch
| File cache_column_names.patch, 2.3 kB (added by lifofifo, 2 years ago) |
|---|
-
activerecord/lib/active_record/base.rb
old new 838 838 839 839 # Returns an array of column objects for the table associated with this class. 840 840 def columns 841 unless @ columns842 @ columns= connection.columns(table_name, "#{name} Columns")843 @ columns.each {|column| column.primary = column.name == primary_key}841 unless @@columns[table_name] 842 @@columns[table_name] = connection.columns(table_name, "#{name} Columns") 843 @@columns[table_name].each {|column| column.primary = column.name == primary_key} 844 844 end 845 @ columns845 @@columns[table_name] 846 846 end 847 848 @@columns = {} 847 849 848 850 # Returns a hash of column objects for the table associated with this class. 849 851 def columns_hash … … 883 885 # Resets all the cached information about columns, which will cause them to be reloaded on the next request. 884 886 def reset_column_information 885 887 read_methods.each { |name| undef_method(name) } 886 @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = @inheritance_column = nil 888 @column_names = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = @inheritance_column = nil 889 @@columns.delete(table_name) 887 890 end 891 892 def reset_column_cache #:nodoc: 893 @@columns = {} 894 end 888 895 889 896 def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc: 890 897 subclasses.each { |klass| klass.reset_inheritable_attributes; klass.reset_column_information } -
railties/lib/dispatcher.rb
old new 59 59 Class.remove_class(*Reloadable.reloadable_classes) 60 60 end 61 61 62 ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord) 62 if defined?(ActiveRecord) 63 ActiveRecord::Base.clear_reloadable_connections! 64 ActiveRecord::Base.reset_column_cache 65 end 63 66 end 64 67 65 68 # Add a preparation callback. Preparation callbacks are run before every