From 941f0196c6c8eade08bf19307bdbedaaeadbe291 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 25 Nov 2012 22:53:46 -0800 Subject: schema cache already has the columns as a hash, so use that Commits 978ec98c8eff824a60c7e973f369cc7bed1f4d36 and 51676652a3568ad09b06385564de4fdcb13af05e changed database statements to use the schema_cache methods, added on master in c99e34e90d763c52cbe8dc3d950ed1b4db665dc4 and dc973e78560a6514ab172f0ee86dc84a9147d39a But apparently the methods weren't added to schema_cache, resulting in the failure described in #8322 for 3-2-stable. Fixes #8322. Conflicts: activerecord/lib/active_record/connection_adapters/schema_cache.rb --- .../connection_adapters/schema_cache.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/connection_adapters/schema_cache.rb b/activerecord/lib/active_record/connection_adapters/schema_cache.rb index 4e8932a695..bc8d24a03f 100644 --- a/activerecord/lib/active_record/connection_adapters/schema_cache.rb +++ b/activerecord/lib/active_record/connection_adapters/schema_cache.rb @@ -1,7 +1,7 @@ module ActiveRecord module ConnectionAdapters class SchemaCache - attr_reader :columns, :columns_hash, :primary_keys, :tables + attr_reader :primary_keys, :tables attr_reader :connection def initialize(conn) @@ -30,6 +30,25 @@ module ActiveRecord @tables[name] = connection.table_exists?(name) end + # Get the columns for a table + def columns(table = nil) + if table + @columns[table] + else + @columns + end + end + + # Get the columns for a table as a hash, key is the column name + # value is the column object. + def columns_hash(table = nil) + if table + @columns_hash[table] + else + @columns_hash + end + end + # Clears out internal caches def clear! @columns.clear -- cgit v1.2.3