mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Fix list parameters in sql queries on pgsql
This commit is contained in:
parent
d0e93f9219
commit
df47e2a93f
@ -253,7 +253,7 @@ to_list(EscapeFun, Val) ->
|
|||||||
|
|
||||||
to_array(EscapeFun, Val) ->
|
to_array(EscapeFun, Val) ->
|
||||||
Escaped = lists:join(<<",">>, lists:map(EscapeFun, Val)),
|
Escaped = lists:join(<<",">>, lists:map(EscapeFun, Val)),
|
||||||
[<<"{">>, Escaped, <<"}">>].
|
lists:flatten([<<"{">>, Escaped, <<"}">>]).
|
||||||
|
|
||||||
to_string_literal(odbc, S) ->
|
to_string_literal(odbc, S) ->
|
||||||
<<"'", (escape(S))/binary, "'">>;
|
<<"'", (escape(S))/binary, "'">>;
|
||||||
@ -776,11 +776,13 @@ pgsql_prepare(SQLQuery, State) ->
|
|||||||
like_escape = fun() -> escape end},
|
like_escape = fun() -> escape end},
|
||||||
{RArgs, _} =
|
{RArgs, _} =
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(arg, {Acc, I}) ->
|
fun(arg, {Acc, I}) ->
|
||||||
{[<<$$, (integer_to_binary(I))/binary>> | Acc], I + 1};
|
{[<<$$, (integer_to_binary(I))/binary>> | Acc], I + 1};
|
||||||
(escape, {Acc, I}) ->
|
(escape, {Acc, I}) ->
|
||||||
{[<<"">> | Acc], I}
|
{[<<"">> | Acc], I};
|
||||||
end, {[], 1}, (SQLQuery#sql_query.args)(Escape)),
|
(List, {Acc, I}) when is_list(List) ->
|
||||||
|
{[<<$$, (integer_to_binary(I))/binary>> | Acc], I + 1}
|
||||||
|
end, {[], 1}, (SQLQuery#sql_query.args)(Escape)),
|
||||||
Args = lists:reverse(RArgs),
|
Args = lists:reverse(RArgs),
|
||||||
%N = length((SQLQuery#sql_query.args)(Escape)),
|
%N = length((SQLQuery#sql_query.args)(Escape)),
|
||||||
%Args = [<<$$, (integer_to_binary(I))/binary>> || I <- lists:seq(1, N)],
|
%Args = [<<$$, (integer_to_binary(I))/binary>> || I <- lists:seq(1, N)],
|
||||||
|
Loading…
Reference in New Issue
Block a user