@@ -62,54 +62,46 @@ map_2({Op, Arg1, Arg2, Arg3}, Fun) ->
62
62
-ifdef (TEST ).
63
63
-include_lib (" eunit/include/eunit.hrl" ).
64
64
65
- has_binary_identifier_test () ->
66
- false = has_binary_identifier (" TRUE" ),
67
- true = has_binary_identifier (" user_key_1 <> 'fake'" ),
68
- false = has_binary_identifier (" properties.subject = 'fake'" ),
69
-
70
- false = has_binary_identifier (" NOT properties.group-id = 'test'" ),
71
- false = has_binary_identifier (" properties.group-sequence IS NULL" ),
72
- false = has_binary_identifier (" properties.group-sequence IS NOT NULL" ),
73
- true = has_binary_identifier (" NOT user_key = 'test'" ),
74
- true = has_binary_identifier (" custom_field IS NULL" ),
75
-
76
- false = has_binary_identifier (" properties.group-id = 'g1' AND header.priority > 5" ),
77
- false = has_binary_identifier (" properties.group-sequence * 10 < 100" ),
78
- false = has_binary_identifier (" properties.creation-time >= 12345 OR properties.subject = 'test'" ),
79
- true = has_binary_identifier (" user_key = 'g1' AND header.priority > 5" ),
80
- true = has_binary_identifier (" header.priority > 5 AND user_key = 'g1'" ),
81
- true = has_binary_identifier (" custom_metric * 10 < 100" ),
82
- true = has_binary_identifier (" properties.creation-time >= 12345 OR user_data = 'test'" ),
83
-
84
- false = has_binary_identifier (" properties.group-id LIKE 'group_%' ESCAPE '!'" ),
85
- true = has_binary_identifier (" user_tag LIKE 'group_%' ESCAPE '!'" ),
86
-
87
- true = has_binary_identifier (" user_category IN ('g1', 'g2', 'g3')" ),
88
- true = has_binary_identifier (" p.group-id IN ('g1', user_key, 'g3')" ),
89
- true = has_binary_identifier (" p.group-id IN ('g1', 'g2', a.user_key)" ),
90
- false = has_binary_identifier (" p.group-id IN (p.reply-to-group-id, 'g2', 'g3')" ),
91
- false = has_binary_identifier (" properties.group-id IN ('g1', 'g2', 'g3')" ),
92
-
93
- false = has_binary_identifier (
94
- " (properties.group-sequence + 1) * 2 <= 100 AND " ++
95
- " (properties.group-id LIKE 'prod_%' OR h.priority > 5)" ),
96
- true = has_binary_identifier (
97
- " (properties.group-sequence + 1) * 2 <= 100 AND " ++
98
- " (user_value LIKE 'prod_%' OR p.absolute-expiry-time < 10)" ),
65
+ search_test () ->
66
+ false = search (" TRUE" ),
67
+ true = search (" user_key_1 <> 'fake'" ),
68
+ false = search (" properties.subject = 'fake'" ),
69
+
70
+ false = search (" NOT properties.group_id = 'test'" ),
71
+ false = search (" properties.group_sequence IS NULL" ),
72
+ false = search (" properties.group_sequence IS NOT NULL" ),
73
+ true = search (" NOT user_key = 'test'" ),
74
+ true = search (" custom_field IS NULL" ),
75
+
76
+ false = search (" properties.group_id = 'g1' AND header.priority > 5" ),
77
+ false = search (" properties.group_sequence * 10 < 100" ),
78
+ false = search (" properties.creation_time >= 12345 OR properties.subject = 'test'" ),
79
+ true = search (" user_key = 'g1' AND header.priority > 5" ),
80
+ true = search (" header.priority > 5 AND user_key = 'g1'" ),
81
+ true = search (" custom_metric * 10 < 100" ),
82
+ true = search (" properties.creation_time >= 12345 OR user_data = 'test'" ),
83
+
84
+ false = search (" properties.group_id LIKE 'group_%' ESCAPE '!'" ),
85
+ true = search (" user_tag LIKE 'group_%' ESCAPE '!'" ),
86
+
87
+ true = search (" user_category IN ('g1', 'g2', 'g3')" ),
88
+ true = search (" p.group_id IN ('g1', user_key, 'g3')" ),
89
+ true = search (" p.group_id IN ('g1', 'g2', a.user_key)" ),
90
+ false = search (" p.group_id IN (p.reply_to_group_id, 'g2', 'g3')" ),
91
+ false = search (" properties.group_id IN ('g1', 'g2', 'g3')" ),
92
+
93
+ false = search (" (properties.group_sequence + 1) * 2 <= 100 AND " ++
94
+ " (properties.group_id LIKE 'prod_%' OR h.priority > 5)" ),
95
+ true = search (" (properties.group_sequence + 1) * 2 <= 100 AND " ++
96
+ " (user_value LIKE 'prod_%' OR p.absolute_expiry_time < 10)" ),
99
97
ok .
100
98
101
- has_binary_identifier (Selector ) ->
99
+ search (Selector ) ->
102
100
{ok , Tokens , _EndLocation } = rabbit_amqp_sql_lexer :string (Selector ),
103
- {ok , Ast0 } = rabbit_amqp_sql_parser :parse (Tokens ),
104
- Ast = map (fun ({identifier , Ident }) when is_binary (Ident ) ->
105
- {identifier , rabbit_amqp_util :section_field_name_to_atom (Ident )};
106
- (Node ) ->
107
- Node
108
- end , Ast0 ),
101
+ {ok , Ast } = rabbit_amqp_sql_parser :parse (Tokens ),
109
102
search (fun ({identifier , Val }) ->
110
103
is_binary (Val );
111
104
(_Node ) ->
112
105
false
113
106
end , Ast ).
114
-
115
107
-endif .
0 commit comments