lib/hanami/model/sql/consoles/postgresql.rb in hanami-model-1.1.0.beta1 vs lib/hanami/model/sql/consoles/postgresql.rb in hanami-model-1.1.0.beta2

- old
+ new

@@ -34,11 +34,11 @@ end # @since 0.7.0 # @api private def host - " -h #{@uri.host}" + " -h #{query['host'] || @uri.host}" end # @since 0.7.0 # @api private def database @@ -46,22 +46,34 @@ end # @since 0.7.0 # @api private def port - " -p #{@uri.port}" unless @uri.port.nil? + port = query['port'] || @uri.port + " -p #{port}" if port end # @since 0.7.0 # @api private def username - " -U #{@uri.user}" unless @uri.user.nil? + username = query['user'] || @uri.user + " -U #{username}" if username end # @since 0.7.0 # @api private def configure_password - ENV[PASSWORD] = CGI.unescape(@uri.password) unless @uri.password.nil? + password = query['password'] || @uri.password + ENV[PASSWORD] = CGI.unescape(query['password'] || @uri.password) if password + end + + # @since 1.1.0 + # @api private + def query + return {} if @uri.query.nil? || @uri.query.empty? + + parsed_query = @uri.query.split("&").map { |a| a.split("=") } + @query ||= Hash[parsed_query] end end end end end