14:30:42.212 [error] Postgrex.Protocol (#PID<0.123.0>) disconnected: ** (Postgrex.QueryError) type `jsonpath` can not be handled by the types module Postgrex.DefaultTypes
So, how can I make Postgrex and Ecto support jsonpath, or how to rewrite the query to avoid such problem? Thanks again.
defmodule MyApp.Postgrex.JSONPath do
@behaviour Postgrex.Extension
@impl Postgrex.Extension
def init(opts) do
Keyword.get(opts, :decode_copy, :copy)
end
@impl Postgrex.Extension
def matching(_state), do: [type: "jsonpath"]
@impl Postgrex.Extension
def format(_state), do: :text
@impl Postgrex.Extension
def encode(_state) do
quote do
bin when is_binary(bin) ->
[<<byte_size(bin) :: signed-size(32)>> | bin]
end
end
@impl Postgrex.Extension
def decode(:reference) do
quote do
<<len::signed-size(32), bin::binary-size(len)>> ->
bin
end
end
def decode(:copy) do
quote do
<<len::signed-size(32), bin::binary-size(len)>> ->
:binary.copy(bin)
end
end
end
But I don’t know if this code is correct. I also don’t know how to configure my Phoenix app so that Postgrex can recognize my type definition.