mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
schema cache already has the columns as a hash, so use that
Commits978ec98c8eand51676652a3changed 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:
committed by
Carlos Antonio da Silva
parent
17d64a1c52
commit
941f0196c6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user