Skip to content

Commit a8275ca

Browse files
authored
Use :socket_dir connection params for mix ecto.load on Postgres (#307)
1 parent 1952ce2 commit a8275ca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/ecto/adapters/postgres.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,15 @@ defmodule Ecto.Adapters.Postgres do
343343
args =
344344
if port = opts[:port], do: ["-p", to_string(port)|args], else: args
345345

346-
host = opts[:hostname] || System.get_env("PGHOST") || "localhost"
346+
host = opts[:socket_dir] || opts[:hostname] || System.get_env("PGHOST") || "localhost"
347+
348+
if opts[:socket] do
349+
IO.warn(
350+
":socket option is ignored when connecting in structure_load/2 and structure_dump/2," <>
351+
" use :socket_dir or :hostname instead"
352+
)
353+
end
354+
347355
args = ["--host", host|args]
348356
args = args ++ opt_args
349357
System.cmd(cmd, args, env: env, stderr_to_stdout: true)

0 commit comments

Comments
 (0)