fix: don't add empty list element to options proplist

This commit is contained in:
Stefan Strigler 2023-01-13 14:46:30 +01:00
parent edfcea7f43
commit 9a53410efb
1 changed files with 17 additions and 15 deletions

View File

@ -111,17 +111,19 @@ on_start(
false -> false ->
[] []
end, end,
Options = [ Options =
maybe_password_opt(maps:get(password, Config, undefined)) maybe_add_password_opt(
| [ maps:get(password, Config, undefined),
{host, Host}, [
{port, Port}, {host, Host},
{user, Username}, {port, Port},
{database, DB}, {user, Username},
{auto_reconnect, ?AUTO_RECONNECT_INTERVAL}, {database, DB},
{pool_size, PoolSize} {auto_reconnect, ?AUTO_RECONNECT_INTERVAL},
] {pool_size, PoolSize}
], ]
),
PoolName = emqx_plugin_libs_pool:pool_name(InstId), PoolName = emqx_plugin_libs_pool:pool_name(InstId),
Prepares = parse_prepare_sql(Config), Prepares = parse_prepare_sql(Config),
State = maps:merge(#{poolname => PoolName}, Prepares), State = maps:merge(#{poolname => PoolName}, Prepares),
@ -136,10 +138,10 @@ on_start(
{error, Reason} {error, Reason}
end. end.
maybe_password_opt(undefined) -> maybe_add_password_opt(undefined, Options) ->
[]; Options;
maybe_password_opt(Password) -> maybe_add_password_opt(Password, Options) ->
{password, Password}. [{password, Password} | Options].
on_stop(InstId, #{poolname := PoolName}) -> on_stop(InstId, #{poolname := PoolName}) ->
?SLOG(info, #{ ?SLOG(info, #{