Skip to content

Commit

Permalink
Eagerly define attribute methods for internal models
Browse files Browse the repository at this point in the history
These models no longer override `table_exists?` to bypass the schema
cache since c5ecc33.
  • Loading branch information
eugeneius committed Nov 6, 2020
1 parent 726f863 commit dcd36ff
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 16 deletions.
4 changes: 0 additions & 4 deletions activerecord/lib/active_record/core.rb
Expand Up @@ -427,10 +427,6 @@ def type_caster # :nodoc:
TypeCaster::Map.new(self)
end

def _internal? # :nodoc:
false
end

def cached_find_by_statement(key, &block) # :nodoc:
cache = @find_by_statement_cache[connection.prepared_statements]
cache.compute_if_absent(key) { StatementCache.create(connection, &block) }
Expand Down
4 changes: 0 additions & 4 deletions activerecord/lib/active_record/internal_metadata.rb
Expand Up @@ -15,10 +15,6 @@ def enabled?
ActiveRecord::Base.connection.use_metadata_table?
end

def _internal?
true
end

def primary_key
"key"
end
Expand Down
4 changes: 0 additions & 4 deletions activerecord/lib/active_record/railtie.rb
Expand Up @@ -166,10 +166,6 @@ class Railtie < Rails::Railtie # :nodoc:
if app.config.eager_load
begin
descendants.each do |model|
# SchemaMigration and InternalMetadata both override `table_exists?`
# to bypass the schema cache, so skip them to avoid the extra queries.
next if model._internal?

# If the schema cache was loaded from a dump, we can use it without connecting
schema_cache = model.connection_pool.schema_cache

Expand Down
4 changes: 0 additions & 4 deletions activerecord/lib/active_record/schema_migration.rb
Expand Up @@ -10,10 +10,6 @@ module ActiveRecord
# to be executed the next time.
class SchemaMigration < ActiveRecord::Base # :nodoc:
class << self
def _internal?
true
end

def primary_key
"version"
end
Expand Down

0 comments on commit dcd36ff

Please sign in to comment.