diff --git a/CHANGELOG.md b/CHANGELOG.md index e912176e56..b36cd59a79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ and this project adheres to ### Fixed +- Error when the logger receives a boolean + [#2666](https://github.com/OpenFn/lightning/issues/2666) + ## [v2.10.1] - 2024-11-13 ### Fixed diff --git a/lib/lightning/ecto_types.ex b/lib/lightning/ecto_types.ex index e335a10221..6888c4a197 100644 --- a/lib/lightning/ecto_types.ex +++ b/lib/lightning/ecto_types.ex @@ -85,6 +85,9 @@ defmodule Lightning.LogMessage do def cast(d) when is_integer(d), do: Ecto.Type.cast(:string, d |> Integer.to_string()) + def cast(d) when is_boolean(d), + do: Ecto.Type.cast(:string, d |> to_string()) + def cast(d) when is_float(d), do: Ecto.Type.cast(:string, d |> Float.to_string()) diff --git a/test/lightning/ecto_types_test.exs b/test/lightning/ecto_types_test.exs index c6fa3135ac..1f6ec49084 100644 --- a/test/lightning/ecto_types_test.exs +++ b/test/lightning/ecto_types_test.exs @@ -31,6 +31,14 @@ defmodule Lightning.EctoTypesTest do assert {:ok, ~s<5.893>} = LogMessage.cast(5.893) end + + test "can be cast from a boolean" do + assert {:ok, ~s} = + LogMessage.cast(true) + + assert {:ok, ~s} = + LogMessage.cast(false) + end end describe "UnixDateTime" do