@@ -22,7 +22,9 @@ create or replace package body ut_suite_tag_filter is
2222 gc_operators constant ut_varchar2_list := ut_varchar2_list('|','&','!');
2323 gc_unary_operators constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator
2424 gc_binary_operators constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator
25-
25+ gc_tags_column_name constant varchar2(250) := 'tags';
26+ gc_exception_msg constant varchar2(200) := 'Invalid tag expression';
27+
2628 type t_precedence_table is table of number index by varchar2(1);
2729 g_precedence t_precedence_table;
2830
@@ -101,7 +103,7 @@ create or replace package body ut_suite_tag_filter is
101103 l_token := a_tags(l_idx);
102104 if (l_token member of gc_operators and l_token member of gc_binary_operators) then
103105 if not(l_expect_operator) then
104- raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression' );
106+ raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg );
105107 end if;
106108 while l_operator_stack.top > 0 and (g_precedence(l_operator_stack.peek) > g_precedence(l_token)) loop
107109 l_rnp_tokens.extend;
@@ -112,21 +114,21 @@ create or replace package body ut_suite_tag_filter is
112114 l_expect_operator:= false;
113115 elsif (l_token member of gc_operators and l_token member of gc_unary_operators) then
114116 if not(l_expect_operand) then
115- raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression' );
117+ raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg );
116118 end if;
117119 l_operator_stack.push(a_tags(l_idx));
118120 l_expect_operand := true;
119121 l_expect_operator:= false;
120122 elsif l_token = '(' then
121123 if not(l_expect_operand) then
122- raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression' );
124+ raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg );
123125 end if;
124126 l_operator_stack.push(a_tags(l_idx));
125127 l_expect_operand := true;
126128 l_expect_operator:= false;
127129 elsif l_token = ')' then
128130 if not(l_expect_operator) then
129- raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression' );
131+ raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg );
130132 end if;
131133 while l_operator_stack.peek <> '(' loop
132134 l_rnp_tokens.extend;
@@ -137,7 +139,7 @@ create or replace package body ut_suite_tag_filter is
137139 l_expect_operator:= true;
138140 else
139141 if not(l_expect_operand) then
140- raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression' );
142+ raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg );
141143 end if;
142144 l_rnp_tokens.extend;
143145 l_rnp_tokens(l_rnp_tokens.last) :=l_token;
@@ -150,7 +152,7 @@ create or replace package body ut_suite_tag_filter is
150152
151153 while l_operator_stack.peek is not null loop
152154 if l_operator_stack.peek in ('(',')') then
153- raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression' );
155+ raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg );
154156 end if;
155157 l_rnp_tokens.extend;
156158 l_rnp_tokens(l_rnp_tokens.last):=l_operator_stack.pop;
@@ -159,23 +161,20 @@ create or replace package body ut_suite_tag_filter is
159161 return l_rnp_tokens;
160162 end shunt_logical_expression;
161163
162- function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list)
164+ function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list,a_tags_column_name in varchar2 )
163165 return varchar2 is
164166 l_infix_stack ut_stack := ut_stack();
165167 l_right_side varchar2(32767);
166168 l_left_side varchar2(32767);
167169 l_infix_exp varchar2(32767);
168- l_member_token varchar2(20) := ' member of tags' ;
170+ l_member_token varchar2(20) := ' member of '||a_tags_column_name ;
169171 l_idx pls_integer;
170172 begin
171173 l_idx := a_postfix_exp.first;
172174 while ( l_idx is not null) loop
173175 --If token is operand but also single tag
174176 if regexp_count(a_postfix_exp(l_idx),'[!()|&]') = 0 then
175177 l_infix_stack.push(q'[']'||a_postfix_exp(l_idx)||q'[']'||l_member_token);
176- --If token is operand but containing other expressions
177- elsif a_postfix_exp(l_idx) not member of gc_operators then
178- l_infix_stack.push(a_postfix_exp(l_idx));
179178 --If token is unary operator not
180179 elsif a_postfix_exp(l_idx) member of gc_unary_operators then
181180 l_right_side := l_infix_stack.pop;
@@ -197,10 +196,9 @@ create or replace package body ut_suite_tag_filter is
197196 function create_where_filter(a_tags varchar2
198197 ) return varchar2 is
199198 l_tags varchar2(4000);
200- l_tokenized_tags ut_varchar2_list;
201199 begin
202200 l_tags := replace(replace_legacy_tag_notation(a_tags),' ');
203- l_tags := conv_postfix_to_infix_sql(shunt_logical_expression(tokenize_tags_string(l_tags)));
201+ l_tags := conv_postfix_to_infix_sql(shunt_logical_expression(tokenize_tags_string(l_tags)),gc_tags_column_name );
204202 l_tags := replace(l_tags, '|',' or ');
205203 l_tags := replace(l_tags ,'&',' and ');
206204 l_tags := replace(l_tags ,'!','not');
@@ -224,7 +222,7 @@ create or replace package body ut_suite_tag_filter is
224222 q'[
225223with
226224 suites_mv as (
227- select c.id,value(c) as obj,c.path as path,c.self_type,c.object_owner,c.tags
225+ select c.id,value(c) as obj,c.path as path,c.self_type,c.object_owner,c.tags as ]'||gc_tags_column_name||q'[
228226 from table(:suite_items) c
229227 ),
230228 suites_matching_expr as (
@@ -234,17 +232,17 @@ with
234232 and ]'||l_tags||q'[
235233 ),
236234 tests_matching_expr as (
237- select c.id,c.path as path,c.self_type,c.object_owner,c.tags
238- from suites_mv c where c.self_type in ('UT_TEST')
235+ select c.id,c.path as path,c.self_type,c.object_owner,c.tags as ]'||gc_tags_column_name||q'[
236+ from suites_mv c where c.self_type in ('UT_TEST')
239237 and ]'||l_tags||q'[
240238 ),
241239 tests_with_tags_inh_from_suite as (
242- select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags tags ,c.object_owner
240+ select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags as ]'||gc_tags_column_name||q'[ ,c.object_owner
243241 from suites_mv c join suites_matching_expr t
244242 on (c.path||'.' like t.path || '.%' /*all descendants and self*/ and c.object_owner = t.object_owner)
245243 ),
246244 tests_with_tags_prom_to_suite as (
247- select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags tags ,c.object_owner
245+ select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags as ]'||gc_tags_column_name||q'[ ,c.object_owner
248246 from suites_mv c join tests_matching_expr t
249247 on (t.path||'.' like c.path || '.%' /*all ancestors and self*/ and c.object_owner = t.object_owner)
250248 )
0 commit comments