Merge pull request #16421 from tsukasaoishi/prevant_manycall_showtables

Tables existence check query is executed in large quantities
This commit is contained in:
Aaron Patterson 2014-08-07 09:40:53 -07:00
commit 69adfc9de6
1 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,7 @@ module ActiveRecord
# A cached lookup for table existence.
def table_exists?(name)
prepare_tables if @tables.empty?
return @tables[name] if @tables.key? name
@tables[name] = connection.table_exists?(name)
@ -82,6 +83,12 @@ module ActiveRecord
def marshal_load(array)
@version, @columns, @columns_hash, @primary_keys, @tables = array
end
private
def prepare_tables
connection.tables.each { |table| @tables[table] = true }
end
end
end
end