feat(rule engine sql): enable both ' and " strings in FROM clause
This commit upgrades the rulesql dependency to version 1.5 instead of 1.4. The difference between these two versions is that strings surrounded by ' and " are supported in FROM clauses in version 1.5, but in version 1.4, only strings surrounded by " are supported. Fixes: https://emqx.atlassian.net/browse/EMQX-9243
This commit is contained in:
parent
082dfc02c9
commit
0e66eb5f3f
|
@ -2634,6 +2634,39 @@ t_sqlparse_invalid_json(_Config) ->
|
|||
}
|
||||
)
|
||||
).
|
||||
|
||||
t_sqlparse_both_string_types_in_from(_Config) ->
|
||||
%% Here is an SQL select statement with both string types in the FROM clause
|
||||
SqlSelect =
|
||||
"select clientid, topic as tp "
|
||||
"from 't/tt', \"$events/client_connected\" ",
|
||||
?assertMatch(
|
||||
{ok, #{<<"clientid">> := <<"abc">>, <<"tp">> := <<"t/tt">>}},
|
||||
emqx_rule_sqltester:test(
|
||||
#{
|
||||
sql => SqlSelect,
|
||||
context => #{clientid => <<"abc">>, topic => <<"t/tt">>}
|
||||
}
|
||||
)
|
||||
),
|
||||
%% Here is an SQL foreach statement with both string types in the FROM clause
|
||||
SqlForeach =
|
||||
"foreach payload.sensors "
|
||||
"from 't/#', \"$events/client_connected\" ",
|
||||
?assertMatch(
|
||||
{ok, []},
|
||||
emqx_rule_sqltester:test(
|
||||
#{
|
||||
sql => SqlForeach,
|
||||
context =>
|
||||
#{
|
||||
payload => <<"{\"sensors\": 1}">>,
|
||||
topic => <<"t/a">>
|
||||
}
|
||||
}
|
||||
)
|
||||
).
|
||||
|
||||
%%------------------------------------------------------------------------------
|
||||
%% Test cases for telemetry functions
|
||||
%%------------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Now, the rule engine language's FROM clause supports both strings enclosed in double quotes (") and single quotes (').
|
|
@ -0,0 +1 @@
|
|||
现在,规则引擎语言的 FROM 子句支持使用双引号(")和单引号(')括起来的字符串。
|
2
mix.exs
2
mix.exs
|
@ -65,7 +65,7 @@ defmodule EMQXUmbrella.MixProject do
|
|||
# maybe forbid to fetch quicer
|
||||
{:emqtt,
|
||||
github: "emqx/emqtt", tag: "1.8.5", override: true, system_env: maybe_no_quic_env()},
|
||||
{:rulesql, github: "emqx/rulesql", tag: "0.1.4"},
|
||||
{:rulesql, github: "emqx/rulesql", tag: "0.1.5"},
|
||||
{:observer_cli, "1.7.1"},
|
||||
{:system_monitor, github: "ieQu1/system_monitor", tag: "3.0.3"},
|
||||
{:telemetry, "1.1.0"},
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
, {replayq, {git, "https://github.com/emqx/replayq.git", {tag, "0.3.7"}}}
|
||||
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
|
||||
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.8.5"}}}
|
||||
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.4"}}}
|
||||
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.5"}}}
|
||||
, {observer_cli, "1.7.1"} % NOTE: depends on recon 2.5.x
|
||||
, {system_monitor, {git, "https://github.com/ieQu1/system_monitor", {tag, "3.0.3"}}}
|
||||
, {getopt, "1.0.2"}
|
||||
|
|
Loading…
Reference in New Issue