Poison support
ppatrzyk opened this issue · 2 comments
Setting Poison as json_library in config leads to the following error in queries:
[error] ** (UndefinedFunctionError) function Poison.encode_to_iodata!/1 is undefined or private
This is due to the following change: #282 . Unfortunately function encode_to_iodata!/1
is no longer present in the latest version of Poison (5.0.0).
For now I found a workaround by having a custom module that maps these names to Poison calls, i.e. doing just the following and putting it as json_library in configuration.
def encode_to_iodata!(data) do
Poison.encode!(data)
end
But would it be maybe possible to set this properly in config - i.e. set exact function for decode / encode? Something like:
config :postgrex,
json_decode: Poison.decode!/1
json_encode: Poison.encode!/1
thanks
My suggestion is to update Poison to add the new function or have a wrapper module. It is a bad practice to have functions in config because they cannot be copied to Erlang configs when assembling a release. :)
@josevalim thank you for a very fast reply, I will continue using a wrapper module then