diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-07 09:40:53 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-07 09:40:53 -0700 |
commit | 69adfc9de6961e368f9023ab1d256affa49e913e (patch) | |
tree | 61e42dc793c76cd8ec38af19fe126317f369e84c /activerecord | |
parent | 12cf864abb27d71d2bb3990fe48beb9b606bc223 (diff) | |
parent | 4e83815ce991efce2b84aa570f6673227ff0bb0d (diff) | |
download | rails-69adfc9de6961e368f9023ab1d256affa49e913e.tar.gz rails-69adfc9de6961e368f9023ab1d256affa49e913e.tar.bz2 rails-69adfc9de6961e368f9023ab1d256affa49e913e.zip |
Merge pull request #16421 from tsukasaoishi/prevant_manycall_showtables
Tables existence check query is executed in large quantities
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/schema_cache.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/schema_cache.rb b/activerecord/lib/active_record/connection_adapters/schema_cache.rb index 3116bed596..a10ce330c7 100644 --- a/activerecord/lib/active_record/connection_adapters/schema_cache.rb +++ b/activerecord/lib/active_record/connection_adapters/schema_cache.rb @@ -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 |