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
Cleanup.
Fix object name length.
  • Loading branch information
lwasylow committed Apr 10, 2023
commit 4b8e2ab124d7819b2a8a442b9fcd31d6d5d5666e
2 changes: 1 addition & 1 deletion 2 source/core/ut_suite_cache_manager.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ create or replace package body ut_suite_cache_manager is
if instr(l_tags,',') > 0 or instr(l_tags,'-') > 0 then
lwasylow marked this conversation as resolved.
Show resolved Hide resolved
l_tags := replace(replace_legacy_tag_notation(l_tags),' ');
end if;
l_tags := ut_utils.convert_postfix_to_infix_where_sql(ut_utils.shunt_logical_expression(l_tags));
l_tags := ut_utils.convert_postfix_to_infix(ut_utils.shunt_logical_expression(l_tags));
l_tags := REPLACE(l_tags, '|',' or ');
lwasylow marked this conversation as resolved.
Show resolved Hide resolved
l_tags := REPLACE(l_tags ,'&',' and ');
l_tags := REPLACE(l_tags ,'!','not');
Expand Down
144 changes: 3 additions & 141 deletions 144 source/core/ut_utils.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -1000,144 +1000,6 @@ create or replace package body ut_utils is
return l_result;
end;

/*
Purpose of this function is to break down the tag expressions
We can separate operators on left and rigth side.
Left ones are AND and OR as they require an operator on left side to
be valid. Right side is NOT.
In each iteration we breakdown string into parts

*/
function valid_tag_expression(a_tags in varchar2) return number is
l_left_side_expression varchar2(10) := '[|&,]';
l_left_side_regex varchar2(50) := '([^|&,]*)[|&,](.*)';
l_left_side varchar2(4000);

l_rigth_side_expression varchar2(10) := '[!-]';
l_right_side_regex varchar2(50) := '([!-])([^!-].*)';
l_right_side varchar2(4000);

l_tags varchar2(4000) := a_tags;
l_result number :=1;
begin
--Validate that we have closed up all brackets
if regexp_count(l_tags,'\(') <> regexp_count(l_tags,'\)') then
l_result := 0;
end if;

--Remove brackets as we dont evaluate expression only validate.
l_tags := replace(replace(l_tags,'('),')');

--Check if there are any left side operators for first in order from left to right
if regexp_count(l_tags,l_left_side_expression) > 0 then
--Extract left part of operator and remaining of string to right
l_left_side := regexp_replace(l_tags,l_left_side_regex,'\1');
l_right_side := regexp_replace(l_tags,l_left_side_regex,'\2');

--If left side is null that means that we used left side operator without
-- left and right e.g. |test
if l_left_side is null then
l_result := 0;
else
--Extract right side from left side expression if there is any !-
--Remove first negation tag to see if there is double negation
l_left_side := regexp_replace(l_left_side,l_right_side_regex,'\2');
end if;


--check that on right side there is no extra negation
if regexp_count(l_left_side,l_rigth_side_expression) > 0 then
l_result := 0;
end if;

--Now process right side of string
if l_right_side is not null then
l_result := least(l_result,valid_tag_expression(l_right_side));
else
l_result := 0;
end if;
else
--We just process single tag.
l_left_side := l_tags;
l_left_side := regexp_replace(l_left_side,l_right_side_regex,'\2');
if regexp_count(l_left_side,l_rigth_side_expression) > 0 then
l_result := 0;
end if;
end if;

return l_result;
end;

procedure build_tag_expression_filter(a_tags in varchar2,a_expression_tab in out t_expression_tab,a_parent_id varchar2 default null) is
l_left_side_expression varchar2(10) := '[|&,]';
l_left_side_regex varchar2(50) := '([^|&,]*)([|&,])(.*)';
l_left_side varchar2(4000);

l_rigth_side_expression varchar2(10) := '[!-]';
l_right_side_regex varchar2(50) := '([!-])([^!-].*)';
l_right_side varchar2(4000);

l_tags varchar2(4000) := a_tags;
l_result number :=1;
l_expression_rec t_expression_rec;

begin
if a_expression_tab is null then
a_expression_tab := t_expression_tab();
end if;

l_expression_rec.id := sys_guid();
l_expression_rec.parent_id := a_parent_id;

if instr(substr(l_tags,1,1),'(',1,1) + instr(substr(l_tags,-1,1),')',-1,1) = 2 then

if regexp_count(l_tags,l_right_side_regex) = 1 then
l_expression_rec.negated :=1;
l_tags := trim (leading '!' from l_tags);
end if;

l_expression_rec.left_bracket := 1;
l_tags := trim(leading '(' from l_tags);
l_expression_rec.right_bracket := 1;
l_tags := trim(trailing ')' from l_tags);
end if;


--Check if there are any left side operators for first in order from left to right
if regexp_count(l_tags,l_left_side_expression) > 0 then
--Extract left part of operator and remaining of string to right

--if there are bracketc extract it and record it

l_left_side := regexp_replace(l_tags,l_left_side_regex,'\1');
l_expression_rec.log_operator := regexp_replace(l_tags,l_left_side_regex,'\2');
l_right_side := regexp_replace(l_tags,l_left_side_regex,'\3');
a_expression_tab.extend;
a_expression_tab(a_expression_tab.last) := l_expression_rec;

build_tag_expression_filter(l_left_side,a_expression_tab,l_expression_rec.id);
build_tag_expression_filter(l_right_side,a_expression_tab,l_expression_rec.id);

else
if instr(substr(l_tags,1,1),'(',1,1) + instr(substr(l_tags,-1,1),')',-1,1) = 2 then

if regexp_count(l_tags,l_right_side_regex) = 1 then
l_expression_rec.negated :=1;
l_tags := trim (leading '!' from l_tags);
end if;

l_expression_rec.left_bracket := 1;
l_tags := trim(leading '(' from l_tags);
l_expression_rec.right_bracket := 1;
l_tags := trim(trailing ')' from l_tags);
end if;
l_expression_rec.expression := l_tags;
a_expression_tab.extend;
a_expression_tab(a_expression_tab.last) := l_expression_rec;
end if;

end;

/*
https://stackoverflow.com/questions/29634992/shunting-yard-validate-expression
*/
Expand Down Expand Up @@ -1251,9 +1113,9 @@ create or replace package body ut_utils is
end loop;

return l_infix_stack.pop;
end;
end convert_postfix_to_infix;

function convert_postfix_to_infix_where_sql(a_postfix_exp in ut_varchar2_list)
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list)
return varchar2 is
l_infix_stack ut_stack := ut_stack();
l_right_side varchar2(32767);
Expand Down Expand Up @@ -1285,7 +1147,7 @@ create or replace package body ut_utils is
end loop;

return l_infix_stack.pop;
end;
end conv_postfix_to_infix_sql;

begin
--Define operator precedence
Expand Down
12 changes: 1 addition & 11 deletions 12 source/core/ut_utils.pks
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,6 @@ create or replace package ut_utils authid definer is
*/
function interval_to_text(a_interval yminterval_unconstrained) return varchar2;

/*
* Return number 1 or 0 if the list of tags is valid expression
*/
function valid_tag_expression(a_tags in varchar2) return number;

/*
* Return number 1 or 0 if the list of tags is valid expression
*/
procedure build_tag_expression_filter(a_tags in varchar2,a_expression_tab in out t_expression_tab,a_parent_id varchar2 default null);

/*
* Function that uses Dijkstra algorithm to parse mathematical and logical expression
* and return a list of elements in Reverse Polish Notation ( postfix )
Expand All @@ -505,7 +495,7 @@ create or replace package ut_utils 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 convert_postfix_to_infix_where_sql(a_postfix_exp in ut_varchar2_list) return varchar2;
function conv_postfix_to_infix_sql(a_postfix_exp in ut_varchar2_list) return varchar2;

end ut_utils;
/
Morty Proxy This is a proxified and sanitized view of the page, visit original site.