Unfortunately this doesn’t quite work:
function :int4.cast/1 is undefined (module :int4 is not available)
But this gave me an idea! I can define a custom type like this:
defmodule Int4 do
@behaviour Ecto.Type
def type, do: :int4
def cast(value), do: {:ok, value}
def load(value), do: {:ok, value}
def dump(value), do: {:ok, value}
end
And now type(^value, Int4) actually does this trick!


















