Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix db object to not return deprecated variable #38920

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,20 +25,17 @@ class DatabaseConfigurations
# database adapter, name, and other important information for database
# connections.
class HashConfig < DatabaseConfig
def initialize(env_name, name, config)
attr_reader :configuration_hash
def initialize(env_name, name, configuration_hash)
super(env_name, name)
@config = config.symbolize_keys
@configuration_hash = configuration_hash.symbolize_keys.freeze
end

def config
ActiveSupport::Deprecation.warn("DatabaseConfig#config will be removed in 6.2.0 in favor of DatabaseConfigurations#configuration_hash which returns a hash with symbol keys")
configuration_hash.stringify_keys
end

def configuration_hash
@config.freeze
end

# Determines whether a database configuration is for a replica / readonly
# connection. If the +replica+ key is present in the config, +replica?+ will
# return +true+.
Expand All @@ -62,7 +59,7 @@ def database
end

def _database=(database) # :nodoc:
@config = configuration_hash.dup.merge(database: database).freeze
@configuration_hash = configuration_hash.merge(database: database).freeze
end

def pool
Expand Down
Expand Up @@ -31,11 +31,11 @@ class DatabaseConfigurations
class UrlConfig < HashConfig
attr_reader :url

def initialize(env_name, name, url, config = {})
super(env_name, name, config)
def initialize(env_name, name, url, configuration_hash = {})
super(env_name, name, configuration_hash)

@url = url
@config.merge!(build_url_hash)
@configuration_hash = @configuration_hash.merge(build_url_hash).freeze
end

private
Expand Down