mirror of https://github.com/rails/rails
Merge pull request #16421 from tsukasaoishi/prevant_manycall_showtables
Tables existence check query is executed in large quantities
This commit is contained in:
commit
69adfc9de6
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue