Skip to content

Commit fddd9bb

Browse files
committed
Remove [NOT] BETWEEN operator
[NOT] BETWEEN operator is not supported in AMQP SQL
1 parent 6b858c4 commit fddd9bb

File tree

7 files changed

+1453
-1903
lines changed

7 files changed

+1453
-1903
lines changed

deps/rabbit/src/rabbit_amqp_filter_sql.erl

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ eval0({unary_minus, Expr}, Msg) ->
158158
end;
159159

160160
%% Special operators
161-
eval0({'between', Expr, From, To}, Msg) ->
162-
Value = eval0(Expr, Msg),
163-
FromVal = eval0(From, Msg),
164-
ToVal = eval0(To, Msg),
165-
between(Value, FromVal, ToVal);
166-
167161
eval0({'in', Expr, ValueList}, Msg) ->
168162
Value = eval0(Expr, Msg),
169163
is_in(Value, ValueList);
@@ -218,21 +212,6 @@ arithmetic('/', Left, Right) when is_number(Left) andalso is_number(Right) andal
218212
arithmetic(_, _, _) ->
219213
undefined.
220214

221-
between(Value, From, To)
222-
when Value =:= undefined orelse
223-
From =:= undefined orelse
224-
To =:= undefined ->
225-
undefined;
226-
between(Value, From, To)
227-
when is_number(Value) andalso
228-
is_number(From) andalso
229-
is_number(To) ->
230-
From =< Value andalso Value =< To;
231-
between(_, _, _) ->
232-
%% BETWEEN requires arithmetic expressions
233-
%% "a string cannot be used in an arithmetic expression"
234-
false.
235-
236215
is_in(undefined, _) ->
237216
%% "If identifier of an IN or NOT IN operation is NULL,
238217
%% the value of the operation is unknown."

deps/rabbit/src/rabbit_amqp_sql_ast.erl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ has_binary_identifier_test() ->
7676
true = has_binary_identifier("custom_metric * 10 < 100"),
7777
true = has_binary_identifier("properties.creation-time >= 12345 OR user_data = 'test'"),
7878

79-
false = has_binary_identifier("properties.group-sequence BETWEEN 1 AND 10"),
80-
true = has_binary_identifier("user_score BETWEEN 1 AND 10"),
81-
8279
false = has_binary_identifier("properties.group-id LIKE 'group_%' ESCAPE '!'"),
8380
true = has_binary_identifier("user_tag LIKE 'group_%' ESCAPE '!'"),
8481

@@ -87,10 +84,10 @@ has_binary_identifier_test() ->
8784

8885
false = has_binary_identifier(
8986
"(properties.group-sequence + 1) * 2 <= 100 AND " ++
90-
"(properties.group-id LIKE 'prod_%' OR header.priority BETWEEN 5 AND 10)"),
87+
"(properties.group-id LIKE 'prod_%' OR h.priority > 5)"),
9188
true = has_binary_identifier(
9289
"(properties.group-sequence + 1) * 2 <= 100 AND " ++
93-
"(user_value LIKE 'prod_%' OR properties.absolute-expiry-time BETWEEN 5 AND 10)"),
90+
"(user_value LIKE 'prod_%' OR p.absolute-expiry-time < 10)"),
9491
ok.
9592

9693
has_binary_identifier(Selector) ->

deps/rabbit/src/rabbit_amqp_sql_lexer.erl

Lines changed: 908 additions & 1111 deletions
Large diffs are not rendered by default.

deps/rabbit/src/rabbit_amqp_sql_lexer.xrl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Rules.
2727
[nN][oO][tT] : {token, {'NOT', TokenLine}}.
2828
2929
% Special operators (case insensitive)
30-
[bB][eE][tT][wW][eE][eE][nN] : {token, {'BETWEEN', TokenLine}}.
3130
[lL][iI][kK][eE] : {token, {'LIKE', TokenLine}}.
3231
[iI][nN] : {token, {'IN', TokenLine}}.
3332
[iI][sS] : {token, {'IS', TokenLine}}.

0 commit comments

Comments
 (0)