aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-02-04 14:52:05 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-02-04 18:14:59 -0800
commitc94651f8c822f7c0778c03eb36bee5ca19f35911 (patch)
treeaf8a771b9c1b15d3d2c8a0adf4c5756fb34c8ee3 /activerecord/lib/active_record
parent0cd42864e3dcba520980f952be9a09c01beddb03 (diff)
downloadrails-c94651f8c822f7c0778c03eb36bee5ca19f35911.tar.gz
rails-c94651f8c822f7c0778c03eb36bee5ca19f35911.tar.bz2
rails-c94651f8c822f7c0778c03eb36bee5ca19f35911.zip
almost fisted
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/base.rb26
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb7
-rw-r--r--activerecord/lib/active_record/session_store.rb4
3 files changed, 15 insertions, 22 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index f8ae855e28..effb17b2ff 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -679,16 +679,12 @@ module ActiveRecord #:nodoc:
# Returns an array of column objects for the table associated with this class.
def columns
- @@columns[table_name] ||= connection.columns(
- table_name, "#{name} Columns"
- ).tap { |columns|
- columns.each { |column| column.primary = column.name == primary_key }
- }
+ connection_pool.columns[table_name]
end
# Returns a hash of column objects for the table associated with this class.
def columns_hash
- @@columns_hash[table_name] ||= Hash[columns.map { |column| [column.name, column] }]
+ connection_pool.columns_hash[table_name]
end
# Returns an array of column names as strings.
@@ -745,21 +741,14 @@ module ActiveRecord #:nodoc:
def reset_column_information
connection.clear_cache!
undefine_attribute_methods
- reset_column_cache
+ connection_pool.clear_table_cache!(table_name) if table_exists?
+
@column_names = @content_columns = @dynamic_methods_hash = @inheritance_column = nil
@arel_engine = @relation = nil
end
def clear_cache! # :nodoc:
- @@columns.clear
- @@columns_hash.clear
- @@arel_tables.clear
- end
-
- def reset_column_cache # :nodoc:
- @@columns.delete table_name
- @@columns_hash.delete table_name
- @@arel_tables.delete table_name
+ connection_pool.clear_cache!
end
def attribute_method?(attribute)
@@ -858,7 +847,7 @@ module ActiveRecord #:nodoc:
end
def arel_table
- @@arel_tables[table_name] ||= Arel::Table.new(table_name, arel_engine)
+ Arel::Table.new(table_name, arel_engine)
end
def arel_engine
@@ -1406,9 +1395,6 @@ MSG
quoted_value
end
end
- @@columns_hash = {}
- @@columns = {}
- @@arel_tables = {}
public
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index db745e325f..63cdce5e4d 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -125,6 +125,13 @@ module ActiveRecord
@primary_keys.clear
end
+ # Clear out internal caches for table with +table_name+
+ def clear_table_cache!(table_name)
+ @columns.delete table_name
+ @columns_hash.delete table_name
+ @primary_keys.delete table_name
+ end
+
# Retrieve the connection associated with the current thread, or call
# #checkout to obtain one if necessary.
#
diff --git a/activerecord/lib/active_record/session_store.rb b/activerecord/lib/active_record/session_store.rb
index e3342f046f..7e77aefb21 100644
--- a/activerecord/lib/active_record/session_store.rb
+++ b/activerecord/lib/active_record/session_store.rb
@@ -59,12 +59,12 @@ module ActiveRecord
end
def drop_table!
- reset_column_cache
+ connection_pool.clear_table_cache!(table_name)
connection.drop_table table_name
end
def create_table!
- reset_column_cache
+ connection_pool.clear_table_cache!(table_name)
connection.create_table(table_name) do |t|
t.string session_id_column, :limit => 255
t.text data_column_name