Browse files

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

Commits

  978ec98 and
  5167665

changed database statements to use the schema_cache methods, added on
master in

  c99e34e and
  dc973e7

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
  • Loading branch information...
1 parent 17d64a1 commit 941f0196c6c8eade08bf19307bdbedaaeadbe291 @tenderlove tenderlove committed with carlosantoniodasilva Nov 25, 2012
Showing with 20 additions and 1 deletion.
  1. +20 −1 activerecord/lib/active_record/connection_adapters/schema_cache.rb
View
21 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 @@ def table_exists?(name)
@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

0 comments on commit 941f019

Please sign in to comment.