Skip to content

Commit

Permalink
Support more integer types in pgsql_util:decode_col
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyshch committed Feb 12, 2016
1 parent af24a41 commit 8cf7aea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pgsql_util.erl
Expand Up @@ -212,9 +212,15 @@ decode_row([Type|TypeTail], [Value|ValueTail], Out0, AsBin) ->
% if AsBin -> Value;
% true -> binary_to_list(Value)
% end;
decode_col({_Name, _Format, _ColNumber, int2, _Size, _Modifier, _TableOID}, Value, _AsBin) ->
<<Int:16/integer>> = Value,
{int2, integer_to_binary(Int)};
decode_col({_Name, _Format, _ColNumber, int4, _Size, _Modifier, _TableOID}, Value, _AsBin) ->
<<Int4:32/integer>> = Value,
{int4, integer_to_binary(Int4)};
<<Int:32/integer>> = Value,
{int4, integer_to_binary(Int)};
decode_col({_Name, _Format, _ColNumber, int8, _Size, _Modifier, _TableOID}, Value, _AsBin) ->
<<Int:64/integer>> = Value,
{int8, integer_to_binary(Int)};
decode_col({_Name, _Format, _ColNumber, Oid, _Size, _Modifier, _TableOID}, Value, _AsBin) ->
{Oid, Value}.

Expand Down

0 comments on commit 8cf7aea

Please sign in to comment.