aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2020-02-27 11:09:44 +0100
committerPaweł Chmielowski <pchmielowski@process-one.net>2020-02-27 11:10:30 +0100
commitdf47e2a93ff8e2c31c8e0dc374588753fe2827c0 (patch)
tree5397a798579b071aa100117168bdacb37ca91e5d
parentMerge pull request #3125 from area-42/enable_odbc_in_mix (diff)
Fix list parameters in sql queries on pgsql
-rw-r--r--src/ejabberd_sql.erl14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/ejabberd_sql.erl b/src/ejabberd_sql.erl
index ebbd9a5cb..461f54e8e 100644
--- a/src/ejabberd_sql.erl
+++ b/src/ejabberd_sql.erl
@@ -253,7 +253,7 @@ to_list(EscapeFun, Val) ->
to_array(EscapeFun, Val) ->
Escaped = lists:join(<<",">>, lists:map(EscapeFun, Val)),
- [<<"{">>, Escaped, <<"}">>].
+ lists:flatten([<<"{">>, Escaped, <<"}">>]).
to_string_literal(odbc, S) ->
<<"'", (escape(S))/binary, "'">>;
@@ -776,11 +776,13 @@ pgsql_prepare(SQLQuery, State) ->
like_escape = fun() -> escape end},
{RArgs, _} =
lists:foldl(
- fun(arg, {Acc, I}) ->
- {[<<$$, (integer_to_binary(I))/binary>> | Acc], I + 1};
- (escape, {Acc, I}) ->
- {[<<"">> | Acc], I}
- end, {[], 1}, (SQLQuery#sql_query.args)(Escape)),
+ fun(arg, {Acc, I}) ->
+ {[<<$$, (integer_to_binary(I))/binary>> | Acc], I + 1};
+ (escape, {Acc, I}) ->
+ {[<<"">> | Acc], I};
+ (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),
%N = length((SQLQuery#sql_query.args)(Escape)),
%Args = [<<$$, (integer_to_binary(I))/binary>> || I <- lists:seq(1, N)],