From 5b82f50feff3c80cbe7a7ae33b078baa1515150a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 9 Dec 2011 11:23:19 -0800 Subject: Use `table_exists?` from the schema cache. --- activerecord/lib/active_record/base.rb | 2 +- activerecord/lib/active_record/connection_adapters/schema_cache.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 58d23d2f78..ba75dc6d09 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -762,7 +762,7 @@ module ActiveRecord #:nodoc: # Indicates whether the table associated with this class exists def table_exists? - connection.table_exists?(table_name) + connection.schema_cache.table_exists?(table_name) end # Returns an array of column objects for the table associated with this class. diff --git a/activerecord/lib/active_record/connection_adapters/schema_cache.rb b/activerecord/lib/active_record/connection_adapters/schema_cache.rb index b14b37ce89..bee03abd44 100644 --- a/activerecord/lib/active_record/connection_adapters/schema_cache.rb +++ b/activerecord/lib/active_record/connection_adapters/schema_cache.rb @@ -42,10 +42,7 @@ module ActiveRecord def table_exists?(name) return @tables[name] if @tables.key? name - connection.tables.each { |table| @tables[table] = true } - @tables[name] = connection.table_exists?(name) if !@tables.key?(name) - - @tables[name] + @tables[name] = connection.table_exists?(name) end # Clears out internal caches: @@ -66,6 +63,7 @@ module ActiveRecord @columns_hash.delete table_name @column_defaults.delete table_name @primary_keys.delete table_name + @tables.delete table_name end end end -- cgit v1.2.3