fix(emqx_rule_engine): Dialyzer warning related to generated code
This commit is contained in:
parent
6a1aae52eb
commit
764d5977c1
|
@ -49,6 +49,10 @@
|
||||||
|
|
||||||
-export_type([select/0]).
|
-export_type([select/0]).
|
||||||
|
|
||||||
|
%% Dialyzer gives up on the generated code.
|
||||||
|
%% probably due to stack depth, or inlines.
|
||||||
|
-dialyzer({nowarn_function, [parse_select/1]}).
|
||||||
|
|
||||||
%% Parse one select statement.
|
%% Parse one select statement.
|
||||||
-spec(parse_select(string() | binary())
|
-spec(parse_select(string() | binary())
|
||||||
-> {ok, select()} | {parse_error, term()} | {lex_error, term()}).
|
-> {ok, select()} | {parse_error, term()} | {lex_error, term()}).
|
||||||
|
@ -76,7 +80,7 @@ parse_select(Sql) ->
|
||||||
end
|
end
|
||||||
catch
|
catch
|
||||||
_Error:Reason:StackTrace ->
|
_Error:Reason:StackTrace ->
|
||||||
{parse_error, Reason, StackTrace}
|
{parse_error, {Reason, StackTrace}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec(select_fields(select()) -> list(field())).
|
-spec(select_fields(select()) -> list(field())).
|
||||||
|
|
|
@ -21,10 +21,18 @@
|
||||||
-export([ test/1
|
-export([ test/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
%% Dialyzer gives up on the generated code.
|
||||||
|
%% probably due to stack depth, or inlines.
|
||||||
|
-dialyzer({nowarn_function, [test/1,
|
||||||
|
test_rule/4,
|
||||||
|
flatten/1,
|
||||||
|
sql_test_action/0,
|
||||||
|
fill_default_values/2
|
||||||
|
]}).
|
||||||
|
|
||||||
-spec(test(#{}) -> {ok, Result::map()} | no_return()).
|
-spec(test(#{}) -> {ok, Result::map()} | no_return()).
|
||||||
test(#{<<"rawsql">> := Sql, <<"ctx">> := Context}) ->
|
test(#{<<"rawsql">> := Sql, <<"ctx">> := Context}) ->
|
||||||
case emqx_rule_sqlparser:parse_select(Sql) of
|
{ok, Select} = emqx_rule_sqlparser:parse_select(Sql),
|
||||||
{ok, Select} ->
|
|
||||||
InTopic = maps:get(<<"topic">>, Context, <<>>),
|
InTopic = maps:get(<<"topic">>, Context, <<>>),
|
||||||
EventTopics = emqx_rule_sqlparser:select_from(Select),
|
EventTopics = emqx_rule_sqlparser:select_from(Select),
|
||||||
case lists:all(fun is_publish_topic/1, EventTopics) of
|
case lists:all(fun is_publish_topic/1, EventTopics) of
|
||||||
|
@ -37,8 +45,6 @@ test(#{<<"rawsql">> := Sql, <<"ctx">> := Context}) ->
|
||||||
false ->
|
false ->
|
||||||
%% the rule is for both publish and events, test it directly
|
%% the rule is for both publish and events, test it directly
|
||||||
test_rule(Sql, Select, Context, EventTopics)
|
test_rule(Sql, Select, Context, EventTopics)
|
||||||
end;
|
|
||||||
Error -> error(Error)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
test_rule(Sql, Select, Context, EventTopics) ->
|
test_rule(Sql, Select, Context, EventTopics) ->
|
||||||
|
|
Loading…
Reference in New Issue