fix(sqlserver): let a single query be a length 1 batch

Need to be fixed:
`emqx_plugin_libs_rule:proc_tmpl/2` won't add single quotes for string
This commit is contained in:
JimMoen 2023-04-10 16:18:29 +08:00
parent a379d909bf
commit 27fdf644aa
No known key found for this signature in database
GPG Key ID: 87A520B4F76BA86D
1 changed files with 11 additions and 8 deletions

View File

@ -502,15 +502,18 @@ parse_sql_template([], SingleInsertTks, BatchInsertTks) ->
%% single insert
apply_template(
{?ACTION_SEND_MESSAGE = Key, Msg} = Query,
#{?SINGLE_INSERT_TEMP := SingleInsertTks} = _Templates
{?ACTION_SEND_MESSAGE = _Key, _Msg} = Query,
#{?SINGLE_INSERT_TEMP := _SingleInsertTks} = Templates
) ->
case maps:get(Key, SingleInsertTks, undefined) of
undefined ->
Query;
Template ->
{Key, emqx_plugin_libs_rule:proc_tmpl(Template, Msg)}
end;
%% TODO: fix emqx_plugin_libs_rule:proc_tmpl/2
%% it won't add single quotes for string
apply_template([Query], Templates);
%% case maps:get(Key, SingleInsertTks, undefined) of
%% undefined ->
%% Query;
%% Template ->
%% {Key, emqx_plugin_libs_rule:proc_tmpl(Template, Msg)}
%% end;
%% batch inserts
apply_template(
[{?ACTION_SEND_MESSAGE = Key, _Msg} | _T] = BatchReqs,