diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-11-25 22:53:46 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-11-26 17:47:04 -0200 |
commit | 941f0196c6c8eade08bf19307bdbedaaeadbe291 (patch) | |
tree | c211f83223b0bb3cf872b6d71e74465a332ca5b6 /activerecord/lib/active_record | |
parent | 17d64a1c5268ec3147de4709517e6607bf96054a (diff) | |
download | rails-941f0196c6c8eade08bf19307bdbedaaeadbe291.tar.gz rails-941f0196c6c8eade08bf19307bdbedaaeadbe291.tar.bz2 rails-941f0196c6c8eade08bf19307bdbedaaeadbe291.zip |
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
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/schema_cache.rb | 21 |
1 files changed, 20 insertions, 1 deletions
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 |