Skip to content

Commit 313d5e9

Browse files
committed
Stage 1 Resolving PR comments
1 parent bd860f6 commit 313d5e9

File tree

9 files changed

+50
-110
lines changed

9 files changed

+50
-110
lines changed

source/api/ut_runner.pkb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ create or replace package body ut_runner is
7878
l_run ut_run;
7979
l_coverage_schema_names ut_varchar2_rows;
8080
l_paths ut_varchar2_list;
81-
l_random_test_order_seed positive;
82-
l_tags varchar2(4000) := a_tags;
83-
81+
l_random_test_order_seed positive;
8482
begin
8583
ut_event_manager.initialize();
8684
if a_reporters is not empty then
@@ -135,10 +133,10 @@ create or replace package body ut_runner is
135133
a_test_file_mappings => set(a_test_file_mappings),
136134
a_client_character_set => a_client_character_set,
137135
a_random_test_order_seed => l_random_test_order_seed,
138-
a_run_tags => l_tags
136+
a_run_tags => a_tags
139137
);
140138

141-
ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, l_tags);
139+
ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, a_tags);
142140
if a_force_manual_rollback then
143141
l_run.set_rollback_type( a_rollback_type => ut_utils.gc_rollback_manual, a_force => true );
144142
end if;

source/core/types/ut_stack.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
create or replace type body ut_stack as
22
/*
33
utPLSQL - Version 3
4-
Copyright 2016 - 2021 utPLSQL Project
4+
Copyright 2016 - 2023 utPLSQL Project
55

66
Licensed under the Apache License, Version 2.0 (the "License"):
77
you may not use this file except in compliance with the License.

source/core/types/ut_stack.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ create or replace type ut_stack as object (
33
tokens ut_varchar2_list,
44
/*
55
utPLSQL - Version 3
6-
Copyright 2016 - 2021 utPLSQL Project
6+
Copyright 2016 - 2023 utPLSQL Project
77

88
Licensed under the Apache License, Version 2.0 (the "License"):
99
you may not use this file except in compliance with the License.

source/core/ut_suite_builder.pkb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ create or replace package body ut_suite_builder is
205205
l_tag_items := ut_utils.trim_list_elements(ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),','));
206206
if l_tag_items is not empty then
207207
for i in 1 .. l_tag_items.count loop
208-
if regexp_like(l_tag_items(i),'^[^-!&|](\S)+$') then
208+
if regexp_like(l_tag_items(i),'^[^-](\S)+$') then
209209
l_tags_list.extend();
210210
l_tags_list(l_tags_list.last) := l_tag_items(i);
211211
else

source/core/ut_suite_cache_manager.pkb

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -238,44 +238,46 @@ create or replace package body ut_suite_cache_manager is
238238
l_tags_exclude varchar2(4000);
239239
l_return_tag varchar2(4000);
240240
begin
241-
select listagg( t.column_value,'|')
242-
within group( order by column_value)
243-
into l_tags_include
244-
from table(l_tags) t
245-
where t.column_value not like '-%';
246-
247-
select listagg( replace(t.column_value,'-','!'),' & ')
248-
within group( order by column_value)
249-
into l_tags_exclude
250-
from table(l_tags) t
251-
where t.column_value like '-%';
252-
253-
l_return_tag:=
254-
case when l_tags_include is not null then
255-
'('||l_tags_include||')' else null end ||
256-
case when l_tags_include is not null and l_tags_exclude is not null then
257-
' & ' else null end ||
258-
case when l_tags_exclude is not null then
259-
'('||l_tags_exclude||')' else null end;
241+
if instr(a_tags,',') > 0 or instr(a_tags,'-') > 0 then
242+
243+
select '('||listagg( t.column_value,'|')
244+
within group( order by column_value)||')'
245+
into l_tags_include
246+
from table(l_tags) t
247+
where t.column_value not like '-%';
260248

249+
select '('||listagg( replace(t.column_value,'-','!'),' & ')
250+
within group( order by column_value)||')'
251+
into l_tags_exclude
252+
from table(l_tags) t
253+
where t.column_value like '-%';
254+
255+
256+
l_return_tag:=
257+
case
258+
when l_tags_include <> '()' and l_tags_exclude <> '()'
259+
then l_tags_include || ' & ' || l_tags_exclude
260+
when l_tags_include <> '()'
261+
then l_tags_include
262+
when l_tags_exclude <> '()'
263+
then l_tags_exclude
264+
end;
265+
else
266+
l_return_tag := a_tags;
267+
end if;
261268
return l_return_tag;
262269
end;
263270

264271
function create_where_filter(a_tags varchar2
265272
) return varchar2 is
266-
l_tags varchar2(4000):= replace(a_tags,' ');
273+
l_tags varchar2(4000);
267274
begin
268-
if instr(l_tags,',') > 0 or instr(l_tags,'-') > 0 then
269-
l_tags := replace(replace_legacy_tag_notation(l_tags),' ');
270-
end if;
275+
l_tags := replace(replace_legacy_tag_notation(a_tags),' ');
271276
l_tags := ut_utils.conv_postfix_to_infix_sql(ut_utils.shunt_logical_expression(l_tags));
272-
l_tags := REPLACE(l_tags, '|',' or ');
273-
l_tags := REPLACE(l_tags ,'&',' and ');
274-
l_tags := REPLACE(l_tags ,'!','not');
275-
return l_tags;
276-
exception
277-
when ut_utils.ex_invalid_tag_expression then
278-
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
277+
l_tags := replace(l_tags, '|',' or ');
278+
l_tags := replace(l_tags ,'&',' and ');
279+
l_tags := replace(l_tags ,'!','not');
280+
return l_tags;
279281
end;
280282

281283
/*

source/core/ut_utils.pkb

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ create or replace package body ut_utils is
2828
* Constants use in postfix and infix transformations
2929
*/
3030
gc_operators constant ut_varchar2_list := ut_varchar2_list('|','&','!');
31-
gc_unary_operator constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator
32-
gc_binary_operator constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator
31+
gc_unary_operators constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator
32+
gc_binary_operators constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator
3333

3434
type t_precedence_table is table of number index by varchar2(1);
3535
g_precedence t_precedence_table;
@@ -1027,9 +1027,9 @@ create or replace package body ut_utils is
10271027
--Exuecute modified shunting algorithm
10281028
WHILE (l_idx is not null) loop
10291029
l_token := l_input_tokens(l_idx);
1030-
if (l_token member of gc_operators and l_token member of gc_binary_operator) then
1030+
if (l_token member of gc_operators and l_token member of gc_binary_operators) then
10311031
if not(l_expect_operator) then
1032-
raise ex_invalid_tag_expression;
1032+
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
10331033
end if;
10341034
while l_operator_stack.top > 0 and (g_precedence(l_operator_stack.peek) > g_precedence(l_token)) loop
10351035
l_rnp_tokens.extend;
@@ -1038,23 +1038,23 @@ create or replace package body ut_utils is
10381038
l_operator_stack.push(l_input_tokens(l_idx));
10391039
l_expect_operand := true;
10401040
l_expect_operator:= false;
1041-
elsif (l_token member of gc_operators and l_token member of gc_unary_operator) then
1041+
elsif (l_token member of gc_operators and l_token member of gc_unary_operators) then
10421042
if not(l_expect_operand) then
1043-
raise ex_invalid_tag_expression;
1043+
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
10441044
end if;
10451045
l_operator_stack.push(l_input_tokens(l_idx));
10461046
l_expect_operand := true;
10471047
l_expect_operator:= false;
10481048
elsif l_token = '(' then
10491049
if not(l_expect_operand) then
1050-
raise ex_invalid_tag_expression;
1050+
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
10511051
end if;
10521052
l_operator_stack.push(l_input_tokens(l_idx));
10531053
l_expect_operand := true;
10541054
l_expect_operator:= false;
10551055
elsif l_token = ')' then
10561056
if not(l_expect_operator) then
1057-
raise ex_invalid_tag_expression;
1057+
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
10581058
end if;
10591059
while l_operator_stack.peek <> '(' loop
10601060
l_rnp_tokens.extend;
@@ -1065,7 +1065,7 @@ create or replace package body ut_utils is
10651065
l_expect_operator:= true;
10661066
else
10671067
if not(l_expect_operand) then
1068-
raise ex_invalid_tag_expression;
1068+
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
10691069
end if;
10701070
l_rnp_tokens.extend;
10711071
l_rnp_tokens(l_rnp_tokens.last) :=l_token;
@@ -1078,7 +1078,7 @@ create or replace package body ut_utils is
10781078

10791079
while l_operator_stack.peek is not null loop
10801080
if l_operator_stack.peek in ('(',')') then
1081-
raise ex_invalid_tag_expression;
1081+
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
10821082
end if;
10831083
l_rnp_tokens.extend;
10841084
l_rnp_tokens(l_rnp_tokens.last):=l_operator_stack.pop;
@@ -1087,37 +1087,6 @@ create or replace package body ut_utils is
10871087
return l_rnp_tokens;
10881088
end shunt_logical_expression;
10891089

1090-
function convert_postfix_to_infix(a_postfix_exp in ut_varchar2_list)
1091-
return varchar2 is
1092-
l_infix_stack ut_stack := ut_stack();
1093-
l_right_side varchar2(32767);
1094-
l_left_side varchar2(32767);
1095-
l_infix_exp varchar2(32767);
1096-
l_idx pls_integer;
1097-
begin
1098-
l_idx := a_postfix_exp.first;
1099-
while (l_idx is not null) loop
1100-
--If token is operand but also single tag
1101-
if a_postfix_exp(l_idx) not member of gc_operators then --its operand
1102-
l_infix_stack.push(a_postfix_exp(l_idx));
1103-
--If token is unary operator not
1104-
elsif a_postfix_exp(l_idx) member of gc_unary_operator then
1105-
l_right_side := l_infix_stack.pop;
1106-
l_infix_exp := '('||a_postfix_exp(l_idx)||l_right_side||')';
1107-
l_infix_stack.push(l_infix_exp);
1108-
--If token is binary operator
1109-
elsif a_postfix_exp(l_idx) member of gc_binary_operator then
1110-
l_right_side := l_infix_stack.pop;
1111-
l_left_side := l_infix_stack.pop;
1112-
l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')';
1113-
l_infix_stack.push(l_infix_exp);
1114-
end if;
1115-
l_idx := a_postfix_exp.next(l_idx);
1116-
end loop;
1117-
1118-
return l_infix_stack.pop;
1119-
end convert_postfix_to_infix;
1120-
11211090
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list)
11221091
return varchar2 is
11231092
l_infix_stack ut_stack := ut_stack();
@@ -1136,12 +1105,12 @@ create or replace package body ut_utils is
11361105
elsif a_postfix_exp(l_idx) not member of gc_operators then
11371106
l_infix_stack.push(a_postfix_exp(l_idx));
11381107
--If token is unary operator not
1139-
elsif a_postfix_exp(l_idx) member of gc_unary_operator then
1108+
elsif a_postfix_exp(l_idx) member of gc_unary_operators then
11401109
l_right_side := l_infix_stack.pop;
11411110
l_infix_exp := a_postfix_exp(l_idx)||'('||l_right_side||')';
11421111
l_infix_stack.push(l_infix_exp);
11431112
--If token is binary operator
1144-
elsif a_postfix_exp(l_idx) member of gc_binary_operator then
1113+
elsif a_postfix_exp(l_idx) member of gc_binary_operators then
11451114
l_right_side := l_infix_stack.pop;
11461115
l_left_side := l_infix_stack.pop;
11471116
l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')';

source/core/ut_utils.pks

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,6 @@ create or replace package ut_utils authid definer is
489489
*/
490490
function shunt_logical_expression(a_tags in varchar2) return ut_varchar2_list;
491491

492-
/*
493-
* Function that converts postfix notation into infix
494-
*/
495-
function convert_postfix_to_infix(a_postfix_exp in ut_varchar2_list) return varchar2;
496-
497492
/*
498493
* Function that converts postfix notation into infix and creating a string of sql filter
499494
* that checking a tags collections for tags according to posted logic.

test/ut3_tester/core/test_ut_utils.pkb

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -511,27 +511,6 @@ end;
511511
ut.expect(l_postfix_string).to_equal('a!b|');
512512
end;
513513

514-
procedure test_conv_from_rpn_to_infix is
515-
l_postfix_rpn ut3_develop.ut_varchar2_list;
516-
l_infix_string varchar2(4000);
517-
begin
518-
l_postfix_rpn := ut3_develop.ut_varchar2_list('A');
519-
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
520-
ut.expect(l_infix_string).to_equal('A');
521-
522-
l_postfix_rpn := ut3_develop.ut_varchar2_list('A','B','|');
523-
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
524-
ut.expect(l_infix_string).to_equal('(A|B)');
525-
526-
l_postfix_rpn := ut3_develop.ut_varchar2_list('a','b','|','c','d','&','|');
527-
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
528-
ut.expect(l_infix_string).to_equal('((a|b)|(c&d))');
529-
530-
l_postfix_rpn := ut3_develop.ut_varchar2_list('a','b','!','|');
531-
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
532-
ut.expect(l_infix_string).to_equal('(a|(!b))');
533-
end;
534-
535514
procedure conv_from_rpn_to_sql_filter is
536515
l_postfix_rpn ut3_develop.ut_varchar2_list;
537516
l_infix_string varchar2(4000);

test/ut3_tester/core/test_ut_utils.pks

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ create or replace package test_ut_utils is
160160
--%test( Test conversion of expression into Reverse Polish Notation)
161161
procedure test_conversion_to_rpn;
162162

163-
--%test( Test conversion of expression from Reverse Polish Notation into infix)
164-
procedure test_conv_from_rpn_to_infix;
165-
166163
--%test( Test conversion of expression from Reverse Polish Notation into custom where filter for SQL)
167164
procedure conv_from_rpn_to_sql_filter;
168165

0 commit comments

Comments
 (0)