Skip to content

Commit 77ed10a

Browse files
committed
fix: workaround to fix PGHOST-related defaults picked by Postgrex
This is a temporary workaround to override any PGHOST-related value that might inadvertently set by default We can revert this once a new Postgrex version >0.20.0 is published See elixir-ecto/postgrex#742 for more information
1 parent 76e3061 commit 77ed10a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/sequin/databases/postgres_database.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ defmodule Sequin.Databases.PostgresDatabase do
186186
|> Enum.to_list()
187187
|> Keyword.put_new(:connect_timeout, @default_connect_timeout)
188188
|> Keyword.put(:types, Sequin.Postgres.PostgrexTypes)
189+
# Temporary workaround to resolve Postgrex endpoint resolving issues if PGHOST is set to a socket or socket directory
190+
# keep this until a new Postgrex version (>0.20.0) is published including this commit
191+
# https://github.com/elixir-ecto/postgrex/commit/412b55567b6f0f3feb587e38466fcab047581c0f
192+
|> Keyword.put(:socket, nil)
193+
|> Keyword.put(:socket_dir, nil)
194+
|> Keyword.put(:endpoints, nil)
189195

190196
# TODO: Remove this when we have CA certs for the cloud providers
191197
# We likely need a bundle that covers many different database providers

test/sequin/databases_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ defmodule Sequin.DatabasesTest do
106106
assert {:error, _} = Databases.tables(db)
107107
assert {:error, _} = Databases.update_tables(db)
108108
end
109+
110+
@tag capture_log: true
111+
test "we are able connect to the database even if PGHOST is set" do
112+
System.put_env("PGHOST", "/something")
113+
on_exit(fn -> System.delete_env("PGHOST") end)
114+
115+
db = DatabasesFactory.insert_configured_postgres_database!()
116+
117+
assert {:ok, _} = Databases.tables(db)
118+
assert {:ok, _} = Databases.update_tables(db)
119+
end
109120
end
110121

111122
describe "to_postgrex_opts/1" do

0 commit comments

Comments
 (0)