Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Feature/1042 add and to tags #1250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Apr 28, 2023
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 11, 2023
commit bf6959fc63c4c36ff24f62d28e8a5b1d6b323ce4
30 changes: 13 additions & 17 deletions 30 source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -1000,24 +1000,30 @@ create or replace package body ut_utils is
return l_result;
end;

function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list is
l_tags_tokens ut_varchar2_list := ut_varchar2_list();
begin
--Tokenize a string into operators and tags
select regexp_substr(a_tags,'([^!()|&]+)|([!()|&])', 1, level) as string_parts
bulk collect into l_tags_tokens
from dual connect by regexp_substr (a_tags, '([^!()|&]+)|([!()|&])', 1, level) is not null;

return l_tags_tokens;
end;

/*
https://stackoverflow.com/questions/29634992/shunting-yard-validate-expression
*/
function shunt_logical_expression(a_tags in varchar2) return ut_varchar2_list is
l_tags varchar2(32767) := a_tags;
l_operator_stack ut_stack := ut_stack();
l_input_tokens ut_varchar2_list := ut_varchar2_list();
l_input_tokens ut_varchar2_list := tokenize_tags_string(a_tags);
l_rnp_tokens ut_varchar2_list := ut_varchar2_list();
l_token varchar2(32767);
l_expect_operand boolean := true;
l_expect_operator boolean := false;
l_idx pls_integer;
begin
--Tokenize a string into operators and tags
select regexp_substr(l_tags,'([^!()|&]+)|([!()|&])', 1, level) as string_parts
bulk collect into l_input_tokens
from dual connect by regexp_substr (l_tags, '([^!()|&]+)|([!()|&])', 1, level) is not null;

l_idx := l_input_tokens.first;
--Exuecute modified shunting algorithm
WHILE (l_idx is not null) loop
Expand Down Expand Up @@ -1071,7 +1077,7 @@ create or replace package body ut_utils is
l_idx := l_input_tokens.next(l_idx);
end loop;

while l_operator_stack.top > 0 loop
while l_operator_stack.peek is not null loop
if l_operator_stack.peek in ('(',')') then
raise ex_invalid_tag_expression;
end if;
Expand All @@ -1082,12 +1088,6 @@ create or replace package body ut_utils is
return l_rnp_tokens;
end shunt_logical_expression;

procedure shunt_logical_expression(a_tags in varchar2) is
a_postfix ut_varchar2_list;
begin
a_postfix := ut_utils.shunt_logical_expression(a_tags);
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();
Expand All @@ -1112,8 +1112,6 @@ create or replace package body ut_utils is
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);
else
null;
end if;
l_idx := a_postfix_exp.next(l_idx);
end loop;
Expand Down Expand Up @@ -1149,8 +1147,6 @@ create or replace package body ut_utils is
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);
else
null;
end if;
l_idx := a_postfix_exp.next(l_idx);
end loop;
Expand Down
7 changes: 5 additions & 2 deletions 7 source/core/ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ create or replace package ut_utils authid definer is
* Return value of interval in plain english
*/
function interval_to_text(a_interval yminterval_unconstrained) return varchar2;

/*
* Return table of tokens character by character
*/
function tokenize_tags_string(a_tags in varchar2) return ut_varchar2_list;

/*
* Function that uses Dijkstra algorithm to parse mathematical and logical expression
Expand All @@ -484,8 +489,6 @@ create or replace package ut_utils authid definer is
*/
function shunt_logical_expression(a_tags in varchar2) return ut_varchar2_list;
lwasylow marked this conversation as resolved.
Show resolved Hide resolved

procedure shunt_logical_expression(a_tags in varchar2);

/*
* Function that converts postfix notation into infix
*/
Expand Down
29 changes: 27 additions & 2 deletions 29 test/ut3_tester/core/test_ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,11 @@ end;

l_postfix := ut3_develop.ut_utils.shunt_logical_expression('(a|b)|c&d');
l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,'');
ut.expect(l_postfix_string).to_equal('ab|cd&|');
ut.expect(l_postfix_string).to_equal('ab|cd&|');

l_postfix := ut3_develop.ut_utils.shunt_logical_expression('!a|b');
l_postfix_string := ut3_develop.ut_utils.table_to_clob(l_postfix,'');
ut.expect(l_postfix_string).to_equal('a!b|');
end;

procedure test_conv_from_rpn_to_infix is
Expand All @@ -521,7 +525,28 @@ end;

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))');
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);
begin
l_postfix_rpn := ut3_develop.ut_varchar2_list('A');
l_infix_string := ut3_develop.ut_utils.conv_postfix_to_infix_sql(l_postfix_rpn);
ut.expect(l_infix_string).to_equal(q'['A' member of tags]');

l_postfix_rpn := ut3_develop.ut_varchar2_list('A','B','|');
l_infix_string := ut3_develop.ut_utils.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_postfix_rpn := ut3_develop.ut_varchar2_list('a','b','!','|');
l_infix_string := ut3_develop.ut_utils.conv_postfix_to_infix_sql(l_postfix_rpn);
ut.expect(l_infix_string).to_equal(q'[('a' member of tags|!('b' member of tags))]');
lwasylow marked this conversation as resolved.
Show resolved Hide resolved
end;

end test_ut_utils;
Expand Down
3 changes: 3 additions & 0 deletions 3 test/ut3_tester/core/test_ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,8 @@ create or replace package test_ut_utils is
--%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;

end test_ut_utils;
/
15 changes: 14 additions & 1 deletion 15 test/ut3_user/api/test_ut_run.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,20 @@ procedure tag_exclude_run_fun_pth_lst_lg is

l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&end_to_end|)');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%');

l_results := ut3_tester_helper.run_helper.run(a_tags => '(!development&!!end_to_end)');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%');

l_results := ut3_tester_helper.run_helper.run(a_tags => '(&development&end_to_end)');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%');

l_results := ut3_tester_helper.run_helper.run(a_tags => '(development|end_to_end))');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).to_match('^\s*invalid_tag_expression \[[,\.0-9]+ sec\]\s*$','m');
ut.expect( ut3_tester_helper.main_helper.table_to_clob(l_results) ).not_to_be_like('%(FAILED -%');

end;

procedure set_application_info is
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.