Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ssl #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sqerl_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ init(CallbackMod) ->
{user, envy:get(sqerl, db_user, string)},
{pass, envy:get(sqerl, db_pass, string)},
{db, envy:get(sqerl, db_name, string)},
{opts, envy:get(sqerl, db_opts, [], list)},
{timeout, envy:get(sqerl,db_timeout, 5000, pos_integer)},
{idle_check, IdleCheck},
{prepared_statements, Statements},
Expand Down
5 changes: 3 additions & 2 deletions src/sqerl_pgsql_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ init(Config) ->
{timeout, Timeout} = lists:keyfind(timeout, 1, Config),
{db, Db} = lists:keyfind(db, 1, Config),
{prepared_statements, Statements} = lists:keyfind(prepared_statements, 1, Config),
Opts = [{database, Db}, {port, Port}, {timeout, Timeout}],
{opts, Opts} = lists:keyfind(opts, 1, Config),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor naming suggestion: call this CustomOpts or Opts0 and then the final thing is Opts that gets passed to pgsql:connect later on.

Opts2 = lists:flatten([Opts | [{database, Db}, {port, Port}, {timeout, Timeout}]]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why lists flatten here instead of: [{database, Db}, {port, Port}, ... | Opts]

CTrans =
case lists:keyfind(column_transforms, 1, Config) of
{column_transforms, CT} -> CT;
false -> undefined
end,
case pgsql:connect(Host, User, Pass, Opts) of
case pgsql:connect(Host, User, Pass, Opts2) of
{error, timeout} ->
{stop, timeout};
{ok, Connection} ->
Expand Down