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
Update tests and code
  • Loading branch information
lwasylow committed Apr 15, 2023
commit 01e53646ba0e37b02ca476832061053e5aa5e786
36 changes: 17 additions & 19 deletions source/core/ut_suite_tag_filter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ create or replace package body ut_suite_tag_filter is
gc_operators constant ut_varchar2_list := ut_varchar2_list('|','&','!');
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

gc_tags_column_name constant varchar2(250) := 'tags';
gc_exception_msg constant varchar2(200) := 'Invalid tag expression';

type t_precedence_table is table of number index by varchar2(1);
g_precedence t_precedence_table;

Expand Down Expand Up @@ -101,7 +103,7 @@ create or replace package body ut_suite_tag_filter is
l_token := a_tags(l_idx);
if (l_token member of gc_operators and l_token member of gc_binary_operators) then
if not(l_expect_operator) then
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg);
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 @@ -112,21 +114,21 @@ create or replace package body ut_suite_tag_filter is
l_expect_operator:= false;
elsif (l_token member of gc_operators and l_token member of gc_unary_operators) then
if not(l_expect_operand) then
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg);
end if;
l_operator_stack.push(a_tags(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif l_token = '(' then
if not(l_expect_operand) then
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg);
end if;
l_operator_stack.push(a_tags(l_idx));
l_expect_operand := true;
l_expect_operator:= false;
elsif l_token = ')' then
if not(l_expect_operator) then
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg);
end if;
while l_operator_stack.peek <> '(' loop
l_rnp_tokens.extend;
Expand All @@ -137,7 +139,7 @@ create or replace package body ut_suite_tag_filter is
l_expect_operator:= true;
else
if not(l_expect_operand) then
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg);
end if;
l_rnp_tokens.extend;
l_rnp_tokens(l_rnp_tokens.last) :=l_token;
Expand All @@ -150,7 +152,7 @@ create or replace package body ut_suite_tag_filter is

while l_operator_stack.peek is not null loop
if l_operator_stack.peek in ('(',')') then
raise_application_error(ut_utils.gc_invalid_tag_expression, 'Invalid Tag expression');
raise_application_error(ut_utils.gc_invalid_tag_expression, gc_exception_msg);
end if;
l_rnp_tokens.extend;
l_rnp_tokens(l_rnp_tokens.last):=l_operator_stack.pop;
Expand All @@ -159,23 +161,20 @@ create or replace package body ut_suite_tag_filter is
return l_rnp_tokens;
end shunt_logical_expression;

function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list)
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list,a_tags_column_name in varchar2)
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_member_token varchar2(20) := ' member of tags';
l_member_token varchar2(20) := ' member of '||a_tags_column_name;
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 regexp_count(a_postfix_exp(l_idx),'[!()|&]') = 0 then
l_infix_stack.push(q'[']'||a_postfix_exp(l_idx)||q'[']'||l_member_token);
--If token is operand but containing other expressions
elsif a_postfix_exp(l_idx) not member of gc_operators then
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_operators then
l_right_side := l_infix_stack.pop;
Expand All @@ -197,10 +196,9 @@ create or replace package body ut_suite_tag_filter is
function create_where_filter(a_tags varchar2
) return varchar2 is
l_tags varchar2(4000);
l_tokenized_tags ut_varchar2_list;
begin
l_tags := replace(replace_legacy_tag_notation(a_tags),' ');
l_tags := conv_postfix_to_infix_sql(shunt_logical_expression(tokenize_tags_string(l_tags)));
l_tags := conv_postfix_to_infix_sql(shunt_logical_expression(tokenize_tags_string(l_tags)),gc_tags_column_name);
l_tags := replace(l_tags, '|',' or ');
l_tags := replace(l_tags ,'&',' and ');
l_tags := replace(l_tags ,'!','not');
Expand All @@ -224,7 +222,7 @@ create or replace package body ut_suite_tag_filter is
q'[
with
suites_mv as (
select c.id,value(c) as obj,c.path as path,c.self_type,c.object_owner,c.tags
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'[
from table(:suite_items) c
),
suites_matching_expr as (
Expand All @@ -234,17 +232,17 @@ with
and ]'||l_tags||q'[
),
tests_matching_expr as (
select c.id,c.path as path,c.self_type,c.object_owner,c.tags
from suites_mv c where c.self_type in ('UT_TEST')
select c.id,c.path as path,c.self_type,c.object_owner,c.tags as ]'||gc_tags_column_name||q'[
from suites_mv c where c.self_type in ('UT_TEST')
and ]'||l_tags||q'[
),
tests_with_tags_inh_from_suite as (
select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags tags,c.object_owner
select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags as ]'||gc_tags_column_name||q'[ ,c.object_owner
from suites_mv c join suites_matching_expr t
on (c.path||'.' like t.path || '.%' /*all descendants and self*/ and c.object_owner = t.object_owner)
),
tests_with_tags_prom_to_suite as (
select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags tags,c.object_owner
select c.id,c.self_type,c.path,c.tags multiset union distinct t.tags as ]'||gc_tags_column_name||q'[ ,c.object_owner
from suites_mv c join tests_matching_expr t
on (t.path||'.' like c.path || '.%' /*all ancestors and self*/ and c.object_owner = t.object_owner)
)
Expand Down
9 changes: 8 additions & 1 deletion source/core/ut_suite_tag_filter.pks
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ create or replace package ut_suite_tag_filter authid definer is
* 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.
*/
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list) return varchar2;
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list,a_tags_column_name in varchar2)
return varchar2;

/*
* Generates a part where clause sql
*/
function create_where_filter(a_tags varchar2)
return varchar2;

function apply(
a_unfiltered_rows ut_suite_cache_rows,
a_tags varchar2 := null
Expand Down
23 changes: 11 additions & 12 deletions test/ut3_tester/core/test_ut_suite_tag_filter.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,20 @@ create or replace package body test_ut_suite_tag_filter is
ut.fail('Expected exception but nothing was raised');
end;

procedure conv_from_rpn_to_sql_filter is
l_postfix_rpn ut3_develop.ut_varchar2_list;
l_infix_string varchar2(4000);
procedure conv_from_tag_to_sql_filter is
l_sql_filter varchar2(4000);
begin
l_postfix_rpn := ut3_develop.ut_varchar2_list('A');
l_infix_string := ut3_develop.ut_suite_tag_filter.conv_postfix_to_infix_sql(l_postfix_rpn);
ut.expect(l_infix_string).to_equal(q'['A' member of tags]');
l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1');
ut.expect(l_sql_filter).to_equal(q'['test1' member of tags]');

l_postfix_rpn := ut3_develop.ut_varchar2_list('A','B','|');
l_infix_string := ut3_develop.ut_suite_tag_filter.conv_postfix_to_infix_sql(l_postfix_rpn);
ut.expect(l_infix_string).to_equal(q'[('A' member of tags|'B' member of tags)]');
l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1|test2');
ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags or 'test2' member of tags)]');

l_postfix_rpn := ut3_develop.ut_varchar2_list('a','b','!','|');
l_infix_string := ut3_develop.ut_suite_tag_filter.conv_postfix_to_infix_sql(l_postfix_rpn);
ut.expect(l_infix_string).to_equal(q'[('a' member of tags|!('b' member of tags))]');
l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1|!test2');
ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags or not('test2' member of tags))]');

l_sql_filter := ut3_develop.ut_suite_tag_filter.create_where_filter('test1&!test2');
ut.expect(l_sql_filter).to_equal(q'[('test1' member of tags and not('test2' member of tags))]');
end;

end test_ut_suite_tag_filter;
Expand Down
4 changes: 2 additions & 2 deletions test/ut3_tester/core/test_ut_suite_tag_filter.pks
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ create or replace package test_ut_suite_tag_filter is

--%endcontext

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

end test_ut_suite_tag_filter;
/