diff --git a/lib/event_store/config.ex b/lib/event_store/config.ex index 418323f..92ebaac 100644 --- a/lib/event_store/config.ex +++ b/lib/event_store/config.ex @@ -151,6 +151,7 @@ defmodule EventStore.Config do # connections (advisory locks and notifications). Uses the default Postgres # configuration if not specified. defp session_mode_pool_config(config) do - Keyword.get(config, :session_mode_pool, config) + config + |> Keyword.merge(Keyword.get(config, :session_mode_pool, [])) end end diff --git a/test/config_test.exs b/test/config_test.exs index 6d5e848..e70232f 100644 --- a/test/config_test.exs +++ b/test/config_test.exs @@ -144,6 +144,38 @@ defmodule EventStore.ConfigTest do ) end + test "passes parent config options to session mode pool config" do + config = [ + ssl: true, + ssl_opts: [cacertfile: ~c"/etc/ssl/certs/db.ca-certificate.crt", verify: :verify_peer], + prepare: :unnamed, + session_mode_url: "postgres://username:password@localhost/database" + ] + + session_mode_pool_config = + Config.parse(config) |> Config.postgrex_notifications_opts(:name) |> Enum.sort() + + assert session_mode_pool_config == [ + auto_reconnect: true, + backoff_type: :exp, + database: "database", + hostname: "localhost", + name: :name, + password: "password", + pool: DBConnection.ConnectionPool, + pool_size: 1, + prepare: :unnamed, + ssl: true, + ssl_opts: [ + cacertfile: ~c"/etc/ssl/certs/db.ca-certificate.crt", + verify: :verify_peer + ], + sync_connect: false, + timeout: 15000, + username: "username" + ] + end + test "parse url with query parameters" do config = [ url: "postgres://username:password@localhost/database?ssl=true&pool_size=5&timeout=120000"