From a8214c9ef54d12168719c766e31d9e7fd5885439 Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Sat, 11 Jan 2025 19:08:26 +0700 Subject: [PATCH 01/10] Bump db_connection Bumps db_connection to drop connection, since connection raises a bunch of deprecation warnings for Elixir 1.18 --- mix.lock | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mix.lock b/mix.lock index fd7becbd..579f49a5 100644 --- a/mix.lock +++ b/mix.lock @@ -1,6 +1,5 @@ %{ - "connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"}, - "db_connection": {:hex, :db_connection, "2.4.1", "6411f6e23f1a8b68a82fa3a36366d4881f21f47fc79a9efb8c615e62050219da", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ea36d226ec5999781a9a8ad64e5d8c4454ecedc7a4d643e4832bf08efca01f00"}, + "db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"}, "decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"}, "earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"}, "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, From 4f2510058c355523dd73d46f43bc87648d6092e5 Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Sat, 11 Jan 2025 19:24:32 +0700 Subject: [PATCH 02/10] Bump Jason --- mix.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.lock b/mix.lock index 579f49a5..b56698c5 100644 --- a/mix.lock +++ b/mix.lock @@ -3,7 +3,7 @@ "decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"}, "earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"}, "ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"}, - "jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "639645cfac325e34938167b272bae0791fea3a34cf32c29525abf1d323ed4c18"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.0", "74bb8348c9b3a51d5c589bf5aebb0466a84b33274150e3b6ece1da45584afc82", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49159b7d7d999e836bedaf09dcf35ca18b312230cf901b725a64f3f42e407983"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"}, From c6883c7f8f5154182c697b30b36bb8a38234ffcb Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Sat, 11 Jan 2025 19:28:24 +0700 Subject: [PATCH 03/10] Change sigil from deprecated sigil_R --- test/login_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/login_test.exs b/test/login_test.exs index 5730c409..bf34a03e 100644 --- a/test/login_test.exs +++ b/test/login_test.exs @@ -62,7 +62,7 @@ defmodule LoginTest do assert {:ok, pid} = P.start_link(context[:options]) assert {:ok, %Postgrex.Result{}} = P.query(pid, "SELECT 123", []) - assert String.match?(P.parameters(pid)["server_version"], ~R"^\d+\.\d+") + assert String.match?(P.parameters(pid)["server_version"], ~r"^\d+\.\d+") end @tag min_pg_version: "9.0" From 460c2b4d177f25d069b3cd43f38603595f9985c9 Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Sat, 11 Jan 2025 22:46:36 +0700 Subject: [PATCH 04/10] Bump Elixir 1.17 ver --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1af61676..e57ef9d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: - pg: version: 14 pair: - elixir: 1.17.1 + elixir: 1.17.2 otp: 25.3 lint: lint env: From 6aa8fb8626f7cdec59f3d227e797bff941d66a88 Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Mon, 13 Jan 2025 22:38:23 +0900 Subject: [PATCH 05/10] Bump Elixir versions --- .github/workflows/ci.yml | 8 ++++---- mix.exs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e57ef9d2..ac169a14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,14 +44,14 @@ jobs: - version: 14 pair: - - elixir: 1.11.4 - otp: 23.3.3 + - elixir: 1.17.2 + otp: 25.3 include: - pg: version: 14 pair: - elixir: 1.17.2 - otp: 25.3 + elixir: 1.18.1 + otp: 27.2 lint: lint env: MIX_ENV: test diff --git a/mix.exs b/mix.exs index d1d3f029..14495d23 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,7 @@ defmodule Postgrex.Mixfile do [ app: :postgrex, version: @version, - elixir: "~> 1.11", + elixir: "~> 1.17", deps: deps(), name: "Postgrex", description: "PostgreSQL driver for Elixir", From 29c4ccd6fc78928905ff651a14cb54368ead0f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 13 Jan 2025 15:28:59 +0100 Subject: [PATCH 06/10] Apply suggestions from code review --- .github/workflows/ci.yml | 4 ++-- mix.exs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac169a14..fc391e3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,8 +44,8 @@ jobs: - version: 14 pair: - - elixir: 1.17.2 - otp: 25.3 + - elixir: 1.11.4 + otp: 23.3.3 include: - pg: version: 14 diff --git a/mix.exs b/mix.exs index 14495d23..d1d3f029 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,7 @@ defmodule Postgrex.Mixfile do [ app: :postgrex, version: @version, - elixir: "~> 1.17", + elixir: "~> 1.11", deps: deps(), name: "Postgrex", description: "PostgreSQL driver for Elixir", From 2429e2f63874d257b6c6a72388c1259e665f1be8 Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Tue, 14 Jan 2025 00:00:57 +0900 Subject: [PATCH 07/10] Conditionally skip test based on Elixir version --- test/postgrex_test.exs | 46 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/test/postgrex_test.exs b/test/postgrex_test.exs index 752e8d18..799deb40 100644 --- a/test/postgrex_test.exs +++ b/test/postgrex_test.exs @@ -1,30 +1,34 @@ defmodule PostgrexTest do use ExUnit.Case, async: false - import ExUnit.CaptureLog - test "start_link/2 sets search path" do - # valid argument - search_path = ["public", "extension"] - {:ok, conn} = Postgrex.start_link(database: "postgrex_test", search_path: search_path) - %{rows: [[result]]} = Postgrex.query!(conn, "show search_path", []) - assert result == Enum.join(search_path, ", ") + # This test fails due to a bug betweem Elixir and Erlang in earlier versions of Elixir. + if Version.match?(Version.parse!(System.version()), Version.parse_requirement!(">= 1.17.2")) do + import ExUnit.CaptureLog - # invalid argument - Process.flag(:trap_exit, true) - search_path = "public, extension" + test "start_link/2 sets search path" do + # valid argument + search_path = ["public", "extension"] + {:ok, conn} = Postgrex.start_link(database: "postgrex_test", search_path: search_path) + %{rows: [[result]]} = Postgrex.query!(conn, "show search_path", []) + assert result == Enum.join(search_path, ", ") - opts = [ - database: "postgrex_test", - search_path: search_path, - show_sensitive_data_on_connection_error: true - ] + # invalid argument + Process.flag(:trap_exit, true) + search_path = "public, extension" - error_log = - capture_log(fn -> - Postgrex.start_link(opts) - assert_receive {:EXIT, _, :killed} - end) + opts = [ + database: "postgrex_test", + search_path: search_path, + show_sensitive_data_on_connection_error: true + ] - assert error_log =~ "expected :search_path to be a list of strings, got: \"#{search_path}\"" + error_log = + capture_log(fn -> + Postgrex.start_link(opts) + assert_receive {:EXIT, _, :killed} + end) + + assert error_log =~ "expected :search_path to be a list of strings, got: \"#{search_path}\"" + end end end From 27ad0dc8bcbcf66b9377c8a6bdcc7b5bcb8b178a Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Tue, 14 Jan 2025 00:08:46 +0900 Subject: [PATCH 08/10] Split out happy path part of skipped test --- test/postgrex_test.exs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/postgrex_test.exs b/test/postgrex_test.exs index 799deb40..174186b1 100644 --- a/test/postgrex_test.exs +++ b/test/postgrex_test.exs @@ -1,17 +1,18 @@ defmodule PostgrexTest do use ExUnit.Case, async: false + import ExUnit.CaptureLog, warn: false - # This test fails due to a bug betweem Elixir and Erlang in earlier versions of Elixir. - if Version.match?(Version.parse!(System.version()), Version.parse_requirement!(">= 1.17.2")) do - import ExUnit.CaptureLog + test "start_link/2 sets search path" do + search_path = ["public", "extension"] + {:ok, conn} = Postgrex.start_link(database: "postgrex_test", search_path: search_path) + %{rows: [[result]]} = Postgrex.query!(conn, "show search_path", []) - test "start_link/2 sets search path" do - # valid argument - search_path = ["public", "extension"] - {:ok, conn} = Postgrex.start_link(database: "postgrex_test", search_path: search_path) - %{rows: [[result]]} = Postgrex.query!(conn, "show search_path", []) - assert result == Enum.join(search_path, ", ") + assert result == Enum.join(search_path, ", ") + end + # This test fails due to a bug betweem Elixir and Erlang in earlier versions of Elixir. + if Version.match?(Version.parse!(System.version()), Version.parse_requirement!(">= 1.17.2")) do + test "start_link/2 detects invalid search path" do # invalid argument Process.flag(:trap_exit, true) search_path = "public, extension" From 66504228c41bd7ff8b4df1bd3efd553db270c964 Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Tue, 14 Jan 2025 00:10:16 +0900 Subject: [PATCH 09/10] Clean up version check --- test/postgrex_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/postgrex_test.exs b/test/postgrex_test.exs index 174186b1..590342a2 100644 --- a/test/postgrex_test.exs +++ b/test/postgrex_test.exs @@ -11,7 +11,7 @@ defmodule PostgrexTest do end # This test fails due to a bug betweem Elixir and Erlang in earlier versions of Elixir. - if Version.match?(Version.parse!(System.version()), Version.parse_requirement!(">= 1.17.2")) do + if Version.match?(System.version(), ">= 1.17.2") do test "start_link/2 detects invalid search path" do # invalid argument Process.flag(:trap_exit, true) From db2ec9680a61a71f54380363cb68ca9b71816451 Mon Sep 17 00:00:00 2001 From: Tyler Witt Date: Tue, 14 Jan 2025 00:18:13 +0900 Subject: [PATCH 10/10] Update test/postgrex_test.exs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: José Valim --- test/postgrex_test.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/postgrex_test.exs b/test/postgrex_test.exs index 590342a2..399fc924 100644 --- a/test/postgrex_test.exs +++ b/test/postgrex_test.exs @@ -10,7 +10,8 @@ defmodule PostgrexTest do assert result == Enum.join(search_path, ", ") end - # This test fails due to a bug betweem Elixir and Erlang in earlier versions of Elixir. + # gen_statem reports are only captured on Elixir v1.17+ + # but a bug causes the Logger to crash on v1.17.0 and v1.17.1. if Version.match?(System.version(), ">= 1.17.2") do test "start_link/2 detects invalid search path" do # invalid argument