aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-02-01 10:37:53 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-02-01 14:25:46 -0800
commit69600a9f97d2f678972500d8a741edc745833718 (patch)
tree587f3091d868afe3aa80eaaafe8c1e819166fa69 /activerecord
parent3cc2b77dc1cb4c1e5cfac68c7828e35a27415e0d (diff)
downloadrails-69600a9f97d2f678972500d8a741edc745833718.tar.gz
rails-69600a9f97d2f678972500d8a741edc745833718.tar.bz2
rails-69600a9f97d2f678972500d8a741edc745833718.zip
avoid column lookup on subclasses, keep column info cached as table_name => column_list
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/base.rb10
-rw-r--r--activerecord/lib/active_record/session_store.rb2
2 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 220d861a27..1e762a287d 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -671,7 +671,11 @@ module ActiveRecord #:nodoc:
# Returns a hash of column objects for the table associated with this class.
def columns_hash
- @columns_hash ||= Hash[columns.map { |column| [column.name, column] }]
+ @@columns_cache[table_name] ||= Hash[columns.map { |column| [column.name, column] }]
+ end
+
+ def columns_hash=(value)
+ @@columns_cache[table_name] = value
end
# Returns an array of column names as strings.
@@ -728,7 +732,8 @@ module ActiveRecord #:nodoc:
def reset_column_information
connection.clear_cache!
undefine_attribute_methods
- @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @inheritance_column = nil
+ self.columns_hash = nil
+ @column_names = @columns = @content_columns = @dynamic_methods_hash = @inheritance_column = nil
@arel_engine = @relation = @arel_table = nil
end
@@ -1376,6 +1381,7 @@ MSG
quoted_value
end
end
+ @@columns_cache = {}
public
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with
diff --git a/activerecord/lib/active_record/session_store.rb b/activerecord/lib/active_record/session_store.rb
index 3400fd6ade..68d9f89edd 100644
--- a/activerecord/lib/active_record/session_store.rb
+++ b/activerecord/lib/active_record/session_store.rb
@@ -59,10 +59,12 @@ module ActiveRecord
end
def drop_table!
+ self.columns_hash = nil
connection.drop_table table_name
end
def create_table!
+ self.columns_hash = nil
connection.create_table(table_name) do |t|
t.string session_id_column, :limit => 255
t.text data_column_name