From 1a0b7ea3c903493dc44b2fd650cd8e7f3b234e46 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 21 Jul 2011 12:57:05 -0700 Subject: adding more tests around database uri parsing --- .../connection_adapters/abstract/connection_specification.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index ca83173d3a..ab07253e86 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -89,8 +89,8 @@ module ActiveRecord end end - def self.connection_url_to_hash(url) - config = URI.parse(url) + def self.connection_url_to_hash(url) # :nodoc: + config = URI.parse url adapter = config.scheme adapter = "postgresql" if adapter == "postgres" spec = { :adapter => adapter, @@ -99,14 +99,12 @@ module ActiveRecord :port => config.port, :database => config.path.sub(%r{^/},""), :host => config.host } - spec.reject!{ |key,value| value.nil? } + spec.reject!{ |_,value| !value } if config.query options = Hash[config.query.split("&").map{ |pair| pair.split("=") }].symbolize_keys spec.merge!(options) end spec - rescue URI::InvalidURIError - return nil end class << self -- cgit v1.2.3