Permalink
Browse files

fix encoding of array lower bound

  • Loading branch information...
1 parent 4c8f96c commit 3318bd5d646cad0623ae9dcc6df015bb85258a63 @wg committed Mar 13, 2012
Showing with 2 additions and 1 deletion.
  1. +1 −1 src/pgsql_binary.erl
  2. +1 −0 test_src/pgsql_tests.erl
@@ -65,7 +65,7 @@ decode(_Other, Bin) -> Bin.
encode_array(Type, A) ->
{Data, {NDims, Lengths}} = encode_array(Type, A, 0, []),
Oid = pgsql_types:type2oid(Type),
- Lens = [<<N:?int32, 0:?int32>> || N <- lists:reverse(Lengths)],
+ Lens = [<<N:?int32, 1:?int32>> || N <- lists:reverse(Lengths)],
Hdr = <<NDims:?int32, 0:?int32, Oid:?int32>>,
Bin = iolist_to_binary([Hdr, Lens, Data]),
<<(byte_size(Bin)):?int32, Bin/binary>>.
@@ -427,6 +427,7 @@ misc_type_test() ->
array_type_test() ->
with_connection(
fun(C) ->
+ {ok, _, [{[1, 2]}]} = pgsql:equery(C, "select ($1::int[])[1:2]", [[1, 2, 3]]),
Select = fun(Type, A) ->
Query = "select $1::" ++ atom_to_list(Type) ++ "[]",
{ok, _Cols, [{A2}]} = pgsql:equery(C, Query, [A]),

0 comments on commit 3318bd5

Please sign in to comment.