diff --git a/src/commands/epgsql_cmd_prepared_query2.erl b/src/commands/epgsql_cmd_prepared_query2.erl index 198ac10..74f27a1 100644 --- a/src/commands/epgsql_cmd_prepared_query2.erl +++ b/src/commands/epgsql_cmd_prepared_query2.erl @@ -44,7 +44,7 @@ execute(Sock, #pquery2{name = Name, params = Params} = State) -> }, {finish, {error, Error}, Sock}; #statement{types = Types} = Stmt -> - TypedParams = lists:zip(Types, Params), + TypedParams = zip(Name, Types, Params), #statement{name = StatementName, columns = Columns} = Stmt, Codec = epgsql_sock:get_codec(Sock), Bin1 = epgsql_wire:encode_parameters(TypedParams, Codec), @@ -58,6 +58,19 @@ execute(Sock, #pquery2{name = Name, params = Params} = State) -> {send_multi, Commands, Sock, State#pquery2{stmt = Stmt}} end. +zip(Name, Types, Params) -> + case length(Types) =:= length(Params) of + true -> + lists:zip(Types, Params); + false -> + error(#{cause => "prepared_data_types_and_column_count_mismatch", + name => Name, + types => Types, + type_count => length(Types), + column_count => length(Params) + }) + end. + %% prepared query handle_message(?BIND_COMPLETE, <<>>, Sock, #pquery2{stmt = Stmt} = State) -> #statement{columns = Columns} = Stmt,