fix(rules): dialyer failed to analysis the emqx_rule_sqlparser:parse/1

This commit is contained in:
Shawn 2021-09-26 16:35:46 +08:00
parent 0d26e50e87
commit e630e23846
3 changed files with 12 additions and 5 deletions

View File

@ -62,6 +62,12 @@ delete_rule(RuleId) ->
%%------------------------------------------------------------------------------
%% Internal Functions
%%------------------------------------------------------------------------------
%% The pattern {'ok', Select} can never match the type {'error',{_,[{_,_,_,_}]}}.
%% probably due to stack depth, or inlines.
-dialyzer({nowarn_function, [do_create_rule/1, parse_outputs/1, do_parse_outputs/1,
pre_process_repub_args/1, preproc_vars/1]}).
do_create_rule(Params = #{id := RuleId, sql := Sql, outputs := Outputs}) ->
case emqx_rule_sqlparser:parse(Sql) of
{ok, Select} ->

View File

@ -237,6 +237,10 @@ param_path_id() ->
%% Rules API
%%------------------------------------------------------------------------------
%% The pattern {'ok', Rule} can never match the type {'error',{_,'invalid_string' | binary() | [tuple()] | {_,[any()]} | {_,'sql_lex',{_,_}}}}
%% probably due to stack depth, or inlines.
-dialyzer({nowarn_function, [crud_rules/2, crud_rules_by_id/2]}).
list_events(#{}, _Params) ->
{200, emqx_rule_events:event_info()}.
@ -283,10 +287,7 @@ crud_rules_by_id(put, #{bindings := #{id := Id}, body := Params0}) ->
crud_rules_by_id(delete, #{bindings := #{id := Id}}) ->
case emqx_rule_engine:delete_rule(Id) of
ok -> {200};
{error, not_found} -> {200};
{error, Reason} ->
?LOG(error, "delete rule failed: ~0p", [Reason]),
{500, #{code => 'UNKNOW_ERROR', message => err_msg(Reason)}}
{error, not_found} -> {200}
end.
%%------------------------------------------------------------------------------

View File

@ -74,7 +74,7 @@ parse(Sql) ->
from = get_value(from, Clauses),
where = get_value(where, Clauses)
}};
{error, Error} -> {error, Error}
Error -> {error, Error}
end
catch
_Error:Reason:StackTrace ->