allow hash interpolation in database configs
test plan: * set something like username: canvas schema_search_path: "%{username},public" in database.yml * it should work Change-Id: I904f83c2ebeea0139e80ac1566a7e934ba3c1eef Reviewed-on: https://gerrit.instructure.com/13806 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jacob Fugal <jacob@instructure.com>
This commit is contained in:
parent
85a1851c8e
commit
71c95cf7f0
|
@ -13,7 +13,13 @@ ActiveRecord::Base::ConnectionSpecification.class_eval do
|
|||
if self.class.environment && @config.has_key?(self.class.environment)
|
||||
@current_config.merge!(@config[self.class.environment].symbolize_keys)
|
||||
end
|
||||
|
||||
@current_config.keys.each do |key|
|
||||
next unless @current_config[key].is_a?(String)
|
||||
@current_config[key] = I18n.interpolate_hash(@current_config[key], @current_config)
|
||||
end
|
||||
@current_config[:username] = @current_config[:username].gsub('{schema}', @current_config[:schema_search_path]) if @current_config[:username] && @current_config[:schema_search_path]
|
||||
|
||||
if self.class.explicit_user
|
||||
@current_config[:username] = self.class.explicit_user
|
||||
@current_config.delete(:password)
|
||||
|
|
|
@ -48,11 +48,11 @@ describe ActiveRecord::Base::ConnectionSpecification do
|
|||
spec.config[:database].should == 'master'
|
||||
end
|
||||
|
||||
it "should allow using {schema} as an insertion into the username" do
|
||||
it "should allow using hash insertions" do
|
||||
conf = {
|
||||
:adapter => 'postgresql',
|
||||
:database => 'master',
|
||||
:username => '{schema}',
|
||||
:username => '%{schema_search_path}',
|
||||
:schema_search_path => 'canvas',
|
||||
:deploy => {
|
||||
:username => 'deploy'
|
||||
|
@ -70,7 +70,7 @@ describe ActiveRecord::Base::ConnectionSpecification do
|
|||
conf = {
|
||||
:adapter => 'postgresql',
|
||||
:database => 'master',
|
||||
:username => '{schema}',
|
||||
:username => '%{schema_search_path}',
|
||||
:schema_search_path => 'canvas',
|
||||
:deploy => {
|
||||
:username => 'deploy'
|
||||
|
|
Loading…
Reference in New Issue