From 887df2797036b416a1e873c93d94a28fcd76a431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Pr=C3=A9vost?= Date: Sun, 22 Sep 2024 12:42:33 -0400 Subject: [PATCH] Add backward-compatible support for Ecto < 3.12 --- lib/absinthe_error_payload/changeset_parser.ex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/absinthe_error_payload/changeset_parser.ex b/lib/absinthe_error_payload/changeset_parser.ex index e9ea037..e7be0bf 100644 --- a/lib/absinthe_error_payload/changeset_parser.ex +++ b/lib/absinthe_error_payload/changeset_parser.ex @@ -139,6 +139,11 @@ defmodule AbsintheErrorPayload.ChangesetParser do defp interpolated_value_to_string(value) when is_list(value), do: Enum.join(value, ",") + # Ecto < 3.12 + defp interpolated_value_to_string({:parameterized, Ecto.Enum, %{on_load: mappings}}), + do: mappings |> Map.values() |> Enum.join(",") + + # Ecto >= 3.12 defp interpolated_value_to_string({:parameterized, {Ecto.Enum, %{on_load: mappings}}}), do: mappings |> Map.values() |> Enum.join(",")