schema cache already has the columns as a hash, so use that

Commits

  978ec98c8e and
  51676652a3

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
This commit is contained in:
Aaron Patterson
2012-11-25 22:53:46 -08:00
committed by Carlos Antonio da Silva
parent 17d64a1c52
commit 941f0196c6

View File

@@ -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