From 025a372b71d128b76f99b75d5eb0bea90ac13b71 Mon Sep 17 00:00:00 2001 From: Marc Nijdam Date: Thu, 25 Feb 2021 10:07:49 -0600 Subject: [PATCH] Port is not present by default --- src/psql_migration.erl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/psql_migration.erl b/src/psql_migration.erl index 5065f72..415ea42 100644 --- a/src/psql_migration.erl +++ b/src/psql_migration.erl @@ -196,7 +196,7 @@ connection_opts(_Args, {url, DatabaseUrl}) -> case uri_string:parse(DatabaseUrl) of {error, Error, Term} -> {error, {Error, Term}}; - #{userinfo := UserPass, port := Port, host := Host, path := Path, query := Query} -> + Map = #{userinfo := UserPass, host := Host, path := Path, query := Query} -> {User, Pass} = case string:split(UserPass, ":") of [[]] -> {"postgres", ""}; @@ -206,11 +206,7 @@ connection_opts(_Args, {url, DatabaseUrl}) -> end, ConnectionOpts = #{ - port => - case Port of - undefined -> 5432; - _ -> Port - end, + port => maps:get(port, Map, 5432), username => User, password => Pass, host => Host,