Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0daab33
Checkpoint
lwasylow Mar 28, 2023
adbc76e
Address too long identified in 11g.
lwasylow Mar 28, 2023
1478b0d
Adding validation for tag expression
lwasylow Mar 29, 2023
b5ad747
Comment out to see why its failing.
lwasylow Mar 29, 2023
06cb054
Revert "Comment out to see why its failing."
lwasylow Mar 29, 2023
e87d39f
Adding validate function, with no calls
lwasylow Mar 29, 2023
97537de
Remove a & from text
lwasylow Mar 29, 2023
2a0f99a
Extra changes and added tests
lwasylow Mar 31, 2023
5b46140
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Mar 31, 2023
b30688c
Address sonar coverage issues.
lwasylow Apr 1, 2023
0c41a0f
Adding tests covering exception of invalid tags
lwasylow Apr 1, 2023
543685d
Removing that , we will not implement that, there is no benefit at th…
lwasylow Apr 1, 2023
0d3cfa1
Removing force
lwasylow Apr 1, 2023
20e3177
Changing to use Dijkstra algorithm to parse infix notation into postf…
lwasylow Apr 10, 2023
f51cc99
Missing slash at end of type
lwasylow Apr 10, 2023
4b8e2ab
Cleanup.
lwasylow Apr 10, 2023
84e8684
Update tests after removed function
lwasylow Apr 10, 2023
2e7a766
Tidy up tests
lwasylow Apr 10, 2023
cbdf83a
Added ut_stack to uninstall
lwasylow Apr 10, 2023
436eb5b
Addressing test failures and sonar smells
lwasylow Apr 11, 2023
3d77514
Update name
lwasylow Apr 11, 2023
bf6959f
Update tests and code
lwasylow Apr 11, 2023
d8233ff
fixing typo in docs
lwasylow Apr 12, 2023
bd860f6
Removed unused variable
lwasylow Apr 12, 2023
313d5e9
Stage 1 Resolving PR comments
lwasylow Apr 13, 2023
02a071c
Separate tag logic.
lwasylow Apr 13, 2023
b8b66ee
Fix uninstall
lwasylow Apr 14, 2023
077fdb1
Various PR fixe
lwasylow Apr 14, 2023
01e5364
Update tests and code
lwasylow Apr 15, 2023
dc0b4a6
Addressing changes via PR review.
lwasylow Apr 18, 2023
ef1c02b
Update docs
lwasylow Apr 18, 2023
1551ea5
Adding any and none
lwasylow Apr 25, 2023
9dee7e0
Update docs
lwasylow Apr 26, 2023
beb9a3a
Resolving PR
lwasylow Apr 27, 2023
46ffe73
Update note
lwasylow Apr 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Stage 1 Resolving PR comments
  • Loading branch information
lwasylow committed Apr 13, 2023
commit 313d5e9019f1253cc222821c802a11c8cdd7ed1a
8 changes: 3 additions & 5 deletions source/api/ut_runner.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ create or replace package body ut_runner is
l_run ut_run;
l_coverage_schema_names ut_varchar2_rows;
l_paths ut_varchar2_list;
l_random_test_order_seed positive;
l_tags varchar2(4000) := a_tags;

l_random_test_order_seed positive;
begin
ut_event_manager.initialize();
if a_reporters is not empty then
Expand Down Expand Up @@ -135,10 +133,10 @@ create or replace package body ut_runner is
a_test_file_mappings => set(a_test_file_mappings),
a_client_character_set => a_client_character_set,
a_random_test_order_seed => l_random_test_order_seed,
a_run_tags => l_tags
a_run_tags => a_tags
);

ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, l_tags);
ut_suite_manager.configure_execution_by_path(l_paths, l_run.items, l_random_test_order_seed, a_tags);
if a_force_manual_rollback then
l_run.set_rollback_type( a_rollback_type => ut_utils.gc_rollback_manual, a_force => true );
end if;
Expand Down
2 changes: 1 addition & 1 deletion source/core/types/ut_stack.tpb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
create or replace type body ut_stack as
/*
utPLSQL - Version 3
Copyright 2016 - 2021 utPLSQL Project
Copyright 2016 - 2023 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion source/core/types/ut_stack.tps
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ create or replace type ut_stack as object (
tokens ut_varchar2_list,
/*
utPLSQL - Version 3
Copyright 2016 - 2021 utPLSQL Project
Copyright 2016 - 2023 utPLSQL Project

Licensed under the Apache License, Version 2.0 (the "License"):
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion source/core/ut_suite_builder.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ create or replace package body ut_suite_builder is
l_tag_items := ut_utils.trim_list_elements(ut_utils.string_to_table(a_tags_ann_text(l_annotation_pos),','));
if l_tag_items is not empty then
for i in 1 .. l_tag_items.count loop
if regexp_like(l_tag_items(i),'^[^-!&|](\S)+$') then
if regexp_like(l_tag_items(i),'^[^-](\S)+$') then
l_tags_list.extend();
l_tags_list(l_tags_list.last) := l_tag_items(i);
else
Expand Down
62 changes: 32 additions & 30 deletions source/core/ut_suite_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -238,44 +238,46 @@ create or replace package body ut_suite_cache_manager is
l_tags_exclude varchar2(4000);
l_return_tag varchar2(4000);
begin
select listagg( t.column_value,'|')
within group( order by column_value)
into l_tags_include
from table(l_tags) t
where t.column_value not like '-%';

select listagg( replace(t.column_value,'-','!'),' & ')
within group( order by column_value)
into l_tags_exclude
from table(l_tags) t
where t.column_value like '-%';

l_return_tag:=
case when l_tags_include is not null then
'('||l_tags_include||')' else null end ||
case when l_tags_include is not null and l_tags_exclude is not null then
' & ' else null end ||
case when l_tags_exclude is not null then
'('||l_tags_exclude||')' else null end;
if instr(a_tags,',') > 0 or instr(a_tags,'-') > 0 then

select '('||listagg( t.column_value,'|')
within group( order by column_value)||')'
into l_tags_include
from table(l_tags) t
where t.column_value not like '-%';

select '('||listagg( replace(t.column_value,'-','!'),' & ')
within group( order by column_value)||')'
into l_tags_exclude
from table(l_tags) t
where t.column_value like '-%';


l_return_tag:=
case
when l_tags_include <> '()' and l_tags_exclude <> '()'
then l_tags_include || ' & ' || l_tags_exclude
when l_tags_include <> '()'
then l_tags_include
when l_tags_exclude <> '()'
then l_tags_exclude
end;
else
l_return_tag := a_tags;
end if;
return l_return_tag;
end;

function create_where_filter(a_tags varchar2
) return varchar2 is
l_tags varchar2(4000):= replace(a_tags,' ');
l_tags varchar2(4000);
begin
if instr(l_tags,',') > 0 or instr(l_tags,'-') > 0 then
l_tags := replace(replace_legacy_tag_notation(l_tags),' ');
end if;
l_tags := replace(replace_legacy_tag_notation(a_tags),' ');
l_tags := ut_utils.conv_postfix_to_infix_sql(ut_utils.shunt_logical_expression(l_tags));
l_tags := REPLACE(l_tags, '|',' or ');
l_tags := REPLACE(l_tags ,'&',' and ');
l_tags := REPLACE(l_tags ,'!','not');
return l_tags;
exception
when ut_utils.ex_invalid_tag_expression then
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
l_tags := replace(l_tags, '|',' or ');
l_tags := replace(l_tags ,'&',' and ');
l_tags := replace(l_tags ,'!','not');
return l_tags;
end;

/*
Expand Down
55 changes: 12 additions & 43 deletions source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ create or replace package body ut_utils is
* Constants use in postfix and infix transformations
*/
gc_operators constant ut_varchar2_list := ut_varchar2_list('|','&','!');
gc_unary_operator constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator
gc_binary_operator constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator
gc_unary_operators constant ut_varchar2_list := ut_varchar2_list('!'); -- right side associative operator
gc_binary_operators constant ut_varchar2_list := ut_varchar2_list('|','&'); -- left side associative operator

type t_precedence_table is table of number index by varchar2(1);
g_precedence t_precedence_table;
Expand Down Expand Up @@ -1027,9 +1027,9 @@ create or replace package body ut_utils is
--Exuecute modified shunting algorithm
WHILE (l_idx is not null) loop
l_token := l_input_tokens(l_idx);
if (l_token member of gc_operators and l_token member of gc_binary_operator) then
if (l_token member of gc_operators and l_token member of gc_binary_operators) then
if not(l_expect_operator) then
raise ex_invalid_tag_expression;
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
end if;
while l_operator_stack.top > 0 and (g_precedence(l_operator_stack.peek) > g_precedence(l_token)) loop
l_rnp_tokens.extend;
Expand All @@ -1038,23 +1038,23 @@ create or replace package body ut_utils is
l_operator_stack.push(l_input_tokens(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif (l_token member of gc_operators and l_token member of gc_unary_operator) then
elsif (l_token member of gc_operators and l_token member of gc_unary_operators) then
if not(l_expect_operand) then
raise ex_invalid_tag_expression;
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
end if;
l_operator_stack.push(l_input_tokens(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif l_token = '(' then
if not(l_expect_operand) then
raise ex_invalid_tag_expression;
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
end if;
l_operator_stack.push(l_input_tokens(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif l_token = ')' then
if not(l_expect_operator) then
raise ex_invalid_tag_expression;
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
end if;
while l_operator_stack.peek <> '(' loop
l_rnp_tokens.extend;
Expand All @@ -1065,7 +1065,7 @@ create or replace package body ut_utils is
l_expect_operator:= true;
else
if not(l_expect_operand) then
raise ex_invalid_tag_expression;
raise_application_error(gc_invalid_tag_expression, 'Invalid Tag expression');
end if;
l_rnp_tokens.extend;
l_rnp_tokens(l_rnp_tokens.last) :=l_token;
Expand All @@ -1078,7 +1078,7 @@ create or replace package body ut_utils is

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

function convert_postfix_to_infix(a_postfix_exp in ut_varchar2_list)
return varchar2 is
l_infix_stack ut_stack := ut_stack();
l_right_side varchar2(32767);
l_left_side varchar2(32767);
l_infix_exp varchar2(32767);
l_idx pls_integer;
begin
l_idx := a_postfix_exp.first;
while (l_idx is not null) loop
--If token is operand but also single tag
if a_postfix_exp(l_idx) not member of gc_operators then --its operand
l_infix_stack.push(a_postfix_exp(l_idx));
--If token is unary operator not
elsif a_postfix_exp(l_idx) member of gc_unary_operator then
l_right_side := l_infix_stack.pop;
l_infix_exp := '('||a_postfix_exp(l_idx)||l_right_side||')';
l_infix_stack.push(l_infix_exp);
--If token is binary operator
elsif a_postfix_exp(l_idx) member of gc_binary_operator then
l_right_side := l_infix_stack.pop;
l_left_side := l_infix_stack.pop;
l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')';
l_infix_stack.push(l_infix_exp);
end if;
l_idx := a_postfix_exp.next(l_idx);
end loop;

return l_infix_stack.pop;
end convert_postfix_to_infix;

function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list)
return varchar2 is
l_infix_stack ut_stack := ut_stack();
Expand All @@ -1136,12 +1105,12 @@ create or replace package body ut_utils is
elsif a_postfix_exp(l_idx) not member of gc_operators then
l_infix_stack.push(a_postfix_exp(l_idx));
Comment thread
lwasylow marked this conversation as resolved.
Outdated
--If token is unary operator not
elsif a_postfix_exp(l_idx) member of gc_unary_operator then
elsif a_postfix_exp(l_idx) member of gc_unary_operators then
l_right_side := l_infix_stack.pop;
l_infix_exp := a_postfix_exp(l_idx)||'('||l_right_side||')';
l_infix_stack.push(l_infix_exp);
--If token is binary operator
elsif a_postfix_exp(l_idx) member of gc_binary_operator then
elsif a_postfix_exp(l_idx) member of gc_binary_operators then
l_right_side := l_infix_stack.pop;
l_left_side := l_infix_stack.pop;
l_infix_exp := '('||l_left_side||a_postfix_exp(l_idx)||l_right_side||')';
Expand Down
5 changes: 0 additions & 5 deletions source/core/ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,6 @@ create or replace package ut_utils authid definer is
*/
function shunt_logical_expression(a_tags in varchar2) return ut_varchar2_list;
Comment thread
lwasylow marked this conversation as resolved.
Outdated

/*
* Function that converts postfix notation into infix
*/
function convert_postfix_to_infix(a_postfix_exp in ut_varchar2_list) return varchar2;

/*
* Function that converts postfix notation into infix and creating a string of sql filter
* that checking a tags collections for tags according to posted logic.
Expand Down
21 changes: 0 additions & 21 deletions test/ut3_tester/core/test_ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -511,27 +511,6 @@ end;
ut.expect(l_postfix_string).to_equal('a!b|');
end;

procedure test_conv_from_rpn_to_infix is
l_postfix_rpn ut3_develop.ut_varchar2_list;
l_infix_string varchar2(4000);
begin
l_postfix_rpn := ut3_develop.ut_varchar2_list('A');
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
ut.expect(l_infix_string).to_equal('A');

l_postfix_rpn := ut3_develop.ut_varchar2_list('A','B','|');
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
ut.expect(l_infix_string).to_equal('(A|B)');

l_postfix_rpn := ut3_develop.ut_varchar2_list('a','b','|','c','d','&','|');
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
ut.expect(l_infix_string).to_equal('((a|b)|(c&d))');

l_postfix_rpn := ut3_develop.ut_varchar2_list('a','b','!','|');
l_infix_string := ut3_develop.ut_utils.convert_postfix_to_infix(l_postfix_rpn);
ut.expect(l_infix_string).to_equal('(a|(!b))');
end;

procedure conv_from_rpn_to_sql_filter is
l_postfix_rpn ut3_develop.ut_varchar2_list;
l_infix_string varchar2(4000);
Expand Down
3 changes: 0 additions & 3 deletions test/ut3_tester/core/test_ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ create or replace package test_ut_utils is
--%test( Test conversion of expression into Reverse Polish Notation)
procedure test_conversion_to_rpn;

--%test( Test conversion of expression from Reverse Polish Notation into infix)
procedure test_conv_from_rpn_to_infix;

--%test( Test conversion of expression from Reverse Polish Notation into custom where filter for SQL)
procedure conv_from_rpn_to_sql_filter;

Expand Down