As it happens, the list_to_float("123") will produce an error:
21> erlang:list_to_float("123").
** exception error: bad argument
in function list_to_float/1
called as list_to_float("123")
22> erlang:list_to_float("123.0").
123.0
That feature was explicitly confirmed by Erlang team, so we have to supply the missing ".0" ourselves. I had to patch the pgsql_util:decode_col locally to make it work:
decode_col(#desc{format=text, type=Float}, Value)
when Float =:= float4; Float =:= float8 ->
ListValue = binary_to_list(Value),
IsFloat = string:str(ListValue,"."),
if
IsFloat > 0 -> FValue = Value;
true -> FValue = Value ++ ".0"
end,
list_to_float(FValue);
2 comments:
Did you fork it on github so I can pull it?
you can find it here
Post a Comment