Handle query dynamically

This commit is contained in:
Marc Nijdam 2021-02-25 10:11:00 -06:00
parent 025a372b71
commit 1211e93d03
No known key found for this signature in database
GPG Key ID: 1C84AFC593B1B79D

View File

@ -196,7 +196,7 @@ connection_opts(_Args, {url, DatabaseUrl}) ->
case uri_string:parse(DatabaseUrl) of
{error, Error, Term} ->
{error, {Error, Term}};
Map = #{userinfo := UserPass, host := Host, path := Path, query := Query} ->
Map = #{userinfo := UserPass, host := Host, path := Path} ->
{User, Pass} =
case string:split(UserPass, ":") of
[[]] -> {"postgres", ""};
@ -213,7 +213,7 @@ connection_opts(_Args, {url, DatabaseUrl}) ->
database => string:slice(Path, 1)
},
case Query of
case maps:get(query, Map, []) of
[] ->
{ok, ConnectionOpts};
"?" ++ QueryString ->