Can't cast `SimpleAggregateFunction(groupArrayArray, Array(DateTime('UTC')))`
hkrutzer opened this issue · 4 comments
hkrutzer commented
This works:
type = Ecto.ParameterizedType.init(Ch, type: "SimpleAggregateFunction(groupArrayArray, Array(String))")
Ecto.Type.cast(type, ["asdf"])
This does not:
type = Ecto.ParameterizedType.init(Ch, type: "SimpleAggregateFunction(groupArrayArray, Array(DateTime('UTC')))")
Ecto.Type.cast(type, [~U[2022-11-24 11:57:23Z]])
** (FunctionClauseError) no function clause matching in Ecto.Type.cast_fun/1
The following arguments were given to Ecto.Type.cast_fun/1:
# 1
{:datetime, "UTC"}
Attempted function clauses (showing 10 out of 25):
defp cast_fun(:integer)
defp cast_fun(:float)
defp cast_fun(:boolean)
defp cast_fun(:map)
defp cast_fun(:string)
defp cast_fun(:binary)
defp cast_fun(:id)
defp cast_fun(:binary_id)
defp cast_fun(:any)
defp cast_fun(:decimal)
...
(15 clauses not shown)
(ecto 3.10.3) lib/ecto/type.ex:761: Ecto.Type.cast_fun/1
(ecto 3.10.3) lib/ecto/type.ex:788: Ecto.Type.cast_fun/1
(ecto 3.10.3) lib/ecto/type.ex:758: Ecto.Type.cast/2
This also does not:
type = Ecto.ParameterizedType.init(Ch, type: "SimpleAggregateFunction(groupArrayArray, Array(UInt8))")
Ecto.Type.cast(type, [1,11,1,1,1])
** (UndefinedFunctionError) function :u8.cast/1 is undefined (module :u8 is not available)
:u8.cast(1)
(ecto 3.10.3) lib/ecto/type.ex:1257: Ecto.Type.array/4
ruslandoga commented
ruslandoga commented
The problem was with casting arrays of Ch
types, fixed in #118
ruslandoga commented
I've published v0.2.1
with that fix.
hkrutzer commented
That was very quick, thank you!