Handle unencodable structs in QueryReporter params

This commit is contained in:
Claudio Ortolina
2026-04-17 07:10:45 +01:00
parent 90838d1a3f
commit bbe1722c9f
+8 -1
View File
@@ -136,7 +136,14 @@ defmodule MusicLibrary.QueryReporter do
end
defp format_param(value) when is_list(value) or (is_map(value) and not is_struct(value)) do
"'" <> String.replace(JSON.encode!(value), "'", "''") <> "'"
encoded =
try do
JSON.encode!(value)
rescue
Protocol.UndefinedError -> inspect(value)
end
"'" <> String.replace(encoded, "'", "''") <> "'"
end
defp format_param(value), do: "'" <> String.replace(to_string(value), "'", "''") <> "'"