fix(emqx_bridge_sqlserver): use empty password by default as it is not a required field

This commit is contained in:
Serge Tupchii 2023-08-31 16:32:19 +03:00
parent 1bf86250dd
commit c54527857a
2 changed files with 3 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_sqlserver, [ {application, emqx_bridge_sqlserver, [
{description, "EMQX Enterprise SQL Server Bridge"}, {description, "EMQX Enterprise SQL Server Bridge"},
{vsn, "0.1.2"}, {vsn, "0.1.3"},
{registered, []}, {registered, []},
{applications, [kernel, stdlib, emqx_resource, odbc]}, {applications, [kernel, stdlib, emqx_resource, odbc]},
{env, []}, {env, []},

View File

@ -173,7 +173,6 @@ on_start(
#{ #{
server := Server, server := Server,
username := Username, username := Username,
password := Password,
driver := Driver, driver := Driver,
database := Database, database := Database,
pool_size := PoolSize, pool_size := PoolSize,
@ -200,7 +199,7 @@ on_start(
Options = [ Options = [
{server, to_bin(Server)}, {server, to_bin(Server)},
{username, Username}, {username, Username},
{password, Password}, {password, emqx_secret:wrap(maps:get(password, Config, ""))},
{driver, Driver}, {driver, Driver},
{database, Database}, {database, Database},
{pool_size, PoolSize} {pool_size, PoolSize}
@ -320,7 +319,7 @@ conn_str([{database, Database} | Opts], Acc) ->
conn_str([{username, Username} | Opts], Acc) -> conn_str([{username, Username} | Opts], Acc) ->
conn_str(Opts, ["UID=" ++ str(Username) | Acc]); conn_str(Opts, ["UID=" ++ str(Username) | Acc]);
conn_str([{password, Password} | Opts], Acc) -> conn_str([{password, Password} | Opts], Acc) ->
conn_str(Opts, ["PWD=" ++ str(Password) | Acc]); conn_str(Opts, ["PWD=" ++ str(emqx_secret:unwrap(Password)) | Acc]);
conn_str([{_, _} | Opts], Acc) -> conn_str([{_, _} | Opts], Acc) ->
conn_str(Opts, Acc). conn_str(Opts, Acc).