Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
42d8d45
Initial check in
lwasylow Oct 6, 2018
2360ca4
First working stab. No messages defined.
lwasylow Oct 6, 2018
dd63970
Include matcher
lwasylow Oct 6, 2018
81240fb
Updated install and deinstall
lwasylow Oct 6, 2018
440670b
Update install
lwasylow Oct 10, 2018
a0ee195
Added tests for include
lwasylow Oct 11, 2018
314b998
Added test for to_contain
lwasylow Oct 11, 2018
6193ff3
Adding negated matcher
lwasylow Oct 11, 2018
f798e39
Added tests and negated code
lwasylow Oct 14, 2018
86276ec
Fixing test dependency on NLS settings.
jgebal Oct 19, 2018
7b037d4
Adding fix to avoid running sonar-scanner on external pull-requests.
jgebal Oct 19, 2018
b2f1b96
Updated project version after build [skip ci]
Oct 19, 2018
80ea7d7
Change CLI version to 3.1.0.
PhilippSalvisberg Oct 19, 2018
3d3a2e8
ignore temporary files created by actions described in CONTRIBUTING.md
PhilippSalvisberg Oct 19, 2018
7170cda
Updated project version after build [skip ci]
Oct 19, 2018
59b1ead
fix to unordered.
lwasylow Oct 20, 2018
4d2a890
Updated project version after build [skip ci]
Oct 20, 2018
29e1bf7
Moving uninstall tests to child job no 2 - (12.1) as it is now fastes…
jgebal Oct 20, 2018
45448ac
Disabling compilation with PLSQL compiler warnings.
jgebal Oct 21, 2018
add5ed8
Updated project version after build [skip ci]
Oct 21, 2018
f39b96a
Update not to include
lwasylow Oct 21, 2018
9557daa
Merge branch 'develop' of github.com:utPLSQL/utPLSQL into feature/mat…
lwasylow Oct 21, 2018
5aa19ea
Update some of the format
lwasylow Oct 21, 2018
03ad5ec
Update documentation
lwasylow Oct 27, 2018
18d89f6
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Nov 1, 2018
74c3648
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Nov 1, 2018
42563e9
Update documentation and added additional test.
lwasylow Nov 1, 2018
3e685e8
Merge branch 'feature/matcher_include' of https://github.com/utPLSQL/…
lwasylow Nov 1, 2018
2a133a1
Fix to issue #770 when the merge statement is run via current user wh…
lwasylow Oct 27, 2018
68d43d6
Added test for min user test
lwasylow Oct 28, 2018
afe9e2c
Update sqlcl download
lwasylow Oct 28, 2018
12edb2a
Squashed commit of the following:
lwasylow Nov 1, 2018
9dbb4e5
Update run test shell.
lwasylow Nov 1, 2018
8752509
Update shell
lwasylow Nov 1, 2018
4138d25
Added extra test for duplicate.
lwasylow Nov 1, 2018
8388276
First stab
lwasylow Nov 3, 2018
9741948
Added belt and braces for big cartesian
lwasylow Nov 4, 2018
be55366
Inserting only first max display rows
lwasylow Nov 5, 2018
ae3d34f
Remove clob transformation
lwasylow Nov 5, 2018
b4113fd
Check in progress of working version.
lwasylow Nov 6, 2018
816a1c1
Beautify sql generation
lwasylow Nov 6, 2018
e5de7d2
Tidy up
lwasylow Nov 6, 2018
9843e14
Code updates for pure sql
lwasylow Nov 8, 2018
ab593d9
Update code to consolidate compare sqls into one place where is gener…
lwasylow Nov 9, 2018
4d3dadc
Update for 11g where error about inline with was raised.
lwasylow Nov 9, 2018
d9ccc83
Fix to sql diff to resolve 11g optimizer rewrite error
lwasylow Nov 9, 2018
c009a86
Update code to bring all code into one place.
lwasylow Nov 10, 2018
ecaf48a
Add some bigger tests
lwasylow Nov 10, 2018
af8b49a
Update rownumber generated
lwasylow Nov 11, 2018
c633ff5
Update code with bug fixes
lwasylow Nov 11, 2018
ee7bdf2
Update order
lwasylow Nov 11, 2018
5b46ab0
Updated code for tests.
lwasylow Nov 12, 2018
c997616
Added cursor info code
lwasylow Nov 13, 2018
2b9d4f3
Capture cursor info and filter it out
lwasylow Nov 15, 2018
fc905ac
Saving progress
lwasylow Nov 16, 2018
107a30b
Updated progress by capturing a nested types in hierarchy structured …
lwasylow Nov 17, 2018
6726f1a
Saving progress
lwasylow Nov 18, 2018
e4043b5
Updates to include nested an collections
lwasylow Nov 19, 2018
6cb5fe7
Further deprecation of Xpath
lwasylow Nov 20, 2018
1356f39
Update to cursor comparision
lwasylow Nov 20, 2018
b094911
Update tests
lwasylow Nov 21, 2018
21dca2b
Resolve issue with nested table being join
lwasylow Nov 21, 2018
6e034bf
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Nov 21, 2018
9dc266e
Update test to be more generic
lwasylow Nov 21, 2018
d96d602
remove schema quantifier
lwasylow Nov 21, 2018
2b90c4b
remove schema quantifier
lwasylow Nov 21, 2018
416df70
Merge branch 'feature/pure_sql' of https://github.com/utPLSQL/utPLSQL…
lwasylow Nov 24, 2018
3759e90
Phase 2. Removal of x path and clean-up deprecated code
lwasylow Nov 26, 2018
35d200c
Merge branch 'develop' of https://github.com/utPLSQL/utPLSQL into fea…
lwasylow Nov 26, 2018
29fe2e1
Update stylecheck
lwasylow Nov 26, 2018
1c0582b
Update test time exec
lwasylow Nov 26, 2018
7837eb4
Anydata refactoring.
lwasylow Nov 28, 2018
e082b75
Improvements to extraction of cursor details using anydata to allow g…
lwasylow Dec 1, 2018
815deac
Updates to documentation
lwasylow Dec 2, 2018
cf0c592
Sorting out some duplicate code.
lwasylow Dec 2, 2018
c156852
Cleanup of code
lwasylow Dec 2, 2018
d8525d6
Change behaviour to compare columns regardless of column position in …
lwasylow Dec 2, 2018
48ad81e
Small fixes and updates regarding peer review.
lwasylow Dec 7, 2018
3ff1e27
Updated paths to venn diagram images
jgebal Dec 9, 2018
69da762
Fixed formatting of examples.
jgebal Dec 9, 2018
8697cea
Added missing synonyms for new matchers `contain / include`
jgebal Dec 9, 2018
1645445
Formatting fixes.
jgebal Dec 9, 2018
62c12cd
Removed unused variables.
jgebal Dec 9, 2018
ca9f8eb
Formatting fixes.
jgebal Dec 9, 2018
004b537
Refactoring recursive calls for resolving complex types in cursor.
jgebal Dec 10, 2018
ada957d
Fixed exception handling on `anytype.getpersistent`
jgebal Dec 10, 2018
2ff110d
Change cursor behaviour to be ordered columns by default.
lwasylow Dec 11, 2018
bd54710
Adding short-name for unordered columns option UC.
lwasylow Dec 11, 2018
6f830dc
Minor formatting and warnings fixed
jgebal Dec 12, 2018
a67b853
Merge branch 'develop' into feature/pure_sql
lwasylow Dec 12, 2018
45643e0
Tidy up code
lwasylow Dec 13, 2018
1e71c99
Adding a new expectation type to specialize unordered_columns only to…
lwasylow Dec 13, 2018
470bb32
A bit of code cleanup
jgebal Jan 3, 2019
b64443d
Fixed cleanup issues.
jgebal Jan 4, 2019
c2d52ae
resolved sonar violations
jgebal Jan 5, 2019
0c994a4
Merge branch 'develop' into feature/pure_sql
jgebal Jan 5, 2019
fab120e
Merge branch 'develop' into feature/pure_sql
jgebal Jan 12, 2019
4663e3b
Merge branch 'develop' into feature/pure_sql
jgebal Jan 13, 2019
9ddc332
Merge branch 'develop' into feature/pure_sql
jgebal Jan 31, 2019
b4483a7
Merge remote-tracking branch 'origin/develop' into feature/pure_sql
jgebal Feb 4, 2019
62e5d80
Fixed doc link
jgebal Feb 4, 2019
d7a2711
Fixed issue with spaces in column lists.
jgebal Feb 5, 2019
97cd079
Improved documentation for `unordered` and `unordered_columns` options.
jgebal Feb 12, 2019
94e58a0
Refactoring - to be continued.
jgebal Feb 14, 2019
08ed9ab
Refactoring - to be continued.
jgebal Feb 15, 2019
90aca9f
Refactoring - to be continued.
jgebal Feb 15, 2019
24c14f9
Refactoring - to be continued.
jgebal Feb 16, 2019
f850428
Fixed issue with DBMS_LOB.COMPARE when empty XML produced.
jgebal Feb 16, 2019
917828c
Refactoring.
jgebal Feb 17, 2019
80563f8
Refactoring.
jgebal Feb 19, 2019
faf3d12
Rework dynamic sql generation to more readible format.
lwasylow Feb 22, 2019
6306af6
Rework dynamic sql generation to more readible format.
lwasylow Feb 22, 2019
daa8ec3
fixing issue with order of data.
lwasylow Feb 23, 2019
ab55d12
fixing issue with order of data.
lwasylow Feb 23, 2019
7676a9a
Merge branch 'feature/pure_sql' of https://github.com/utPLSQL/utPLSQL…
lwasylow Feb 23, 2019
dd7e868
Renamed `ut_include` to `ut_contain`.
jgebal Feb 24, 2019
9fccd1d
Wrapping up anydata into cursor
lwasylow Feb 23, 2019
6421ec8
Merge branch 'feature/pure_sql' of https://github.com/utPLSQL/utPLSQL…
lwasylow Feb 24, 2019
061895a
Wrapping up anydata into cursor
lwasylow Feb 24, 2019
7bb5533
Fixing issue with null object and counts
lwasylow Feb 26, 2019
147a506
Fixing issues with null and empty objects / collections
lwasylow Mar 1, 2019
5dd4d42
Shorter tests names and removal of unused types files.
lwasylow Mar 2, 2019
01e93e7
Wrapping in the quota column name in cursor as it uses a type value w…
lwasylow Mar 2, 2019
2c8cd32
Fixing issue with refcursor in anydata.
lwasylow Mar 4, 2019
bbb9020
Adding cursor closure
lwasylow Mar 4, 2019
09b43da
Adding in out
lwasylow Mar 4, 2019
9961dbc
Testing fix for issue with cursors
lwasylow Mar 5, 2019
2534c96
fixing cursor issue
lwasylow Mar 5, 2019
dea6d3c
Refactoring.
lwasylow Mar 5, 2019
bf4a25a
Merge branch 'feature/pure_sql' of https://github.com/utPLSQL/utPLSQL…
lwasylow Mar 6, 2019
e32d700
Refactoring
lwasylow Mar 6, 2019
2dab607
Merge branch 'develop' into feature/pure_sql
lwasylow Mar 6, 2019
5c1ef69
Update sonar sh
lwasylow Mar 6, 2019
b91ea69
Fixing SONAR errors
lwasylow Mar 6, 2019
e8e5772
Merge branch 'feature/pure_sql' of https://github.com/utPLSQL/utPLSQL…
lwasylow Mar 6, 2019
7a77a7f
small improvments
lwasylow Mar 8, 2019
cfada15
Remove tests as its not replicating issue
lwasylow Mar 8, 2019
b823922
Merge branch 'develop' into feature/pure_sql
jgebal Mar 8, 2019
c583319
Adding extra tests for collection with join_by and unordered
lwasylow Mar 12, 2019
46fb8ff
Merge branch 'feature/pure_sql' of https://github.com/utPLSQL/utPLSQL…
lwasylow Mar 12, 2019
3aa872b
Updated docs/userguide/advanced_data_comparison.md
lwasylow Mar 12, 2019
3e4e1a8
Fixing a conversion of date when extracting XML DATE,TS, TS_TZ,TS_LTS…
lwasylow Mar 14, 2019
898bec2
Fixed support for different DATE NLS settings.
jgebal Mar 15, 2019
6590735
Merge remote-tracking branch 'origin/develop' into feature/pure_sql
jgebal Mar 15, 2019
05adfa2
Moving expectations for compound into single type and removing expect…
lwasylow Mar 15, 2019
ca64da8
Merge branch 'feature/pure_sql' of https://github.com/utPLSQL/utPLSQL…
lwasylow Mar 15, 2019
10a6bf7
Update docs
lwasylow Mar 15, 2019
76c068e
Merge branch 'develop' into feature/pure_sql
lwasylow Mar 15, 2019
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 code to consolidate compare sqls into one place where is gener…
…ated dynamically
  • Loading branch information
lwasylow committed Nov 9, 2018
commit ab593d97bd34b5399fd5d8f4c8f73dc13dadf1d4
184 changes: 74 additions & 110 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ create or replace package body ut_compound_data_helper is
l_data ut_data_value := a_column_details.value;
l_key varchar2(4000) := ut_utils.xmlgen_escaped_string(a_column_details.KEY);
l_is_diff number;
begin
begin
l_result := '<'||l_key||' xml_valid_name="'||l_key;
if l_data is of(ut_data_value_xmltype) then
l_result := l_result||'" sql_diffable="0">' || (treat(l_data as ut_data_value_xmltype).to_string);
l_result := l_result||'" sql_diffable="0" user_defined="1" >' ||trim( both '''' from (treat(l_data as ut_data_value_xmltype).to_string));
else
l_is_diff := ut_curr_usr_compound_helper.is_sql_compare_int((treat(l_data as ut_data_value_varchar2).data_value));
l_result := l_result||'" sql_diffable="'||l_is_diff||'">' || ut_utils.xmlgen_escaped_string((treat(l_data as ut_data_value_varchar2).data_value));
l_result := l_result||'" sql_diffable="'||l_is_diff||'" user_defined="0">' || ut_utils.xmlgen_escaped_string((treat(l_data as ut_data_value_varchar2).data_value));
end if;

l_result := l_result ||'</'||l_key||'>';
l_result := l_result ||'</'||l_key||'>';
return xmltype(l_result);
end;

Expand Down Expand Up @@ -202,6 +201,8 @@ create or replace package body ut_compound_data_helper is
from diff_info i,
table( xmlsequence( extract(i.act_item_data,'/*/*') ) ) s
where i.act_data_id = :other_guid)
select rn, diff_type, diffed_row, pk_value pk_value
from (
select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, pk_value pk_value
from (
select nvl(exp.rn, act.rn) rn, nvl(exp.pk_value, act.pk_value) pk_value, exp.col exp_item, act.col act_item
Expand All @@ -215,7 +216,8 @@ create or replace package body ut_compound_data_helper is
nvl2(i.join_by,ut3.ut_compound_data_helper.get_pk_value(i.join_by,case when exp_data_id is null then act_item_data else exp_item_data end),null) pk_value
from diff_info i
where act_data_id is null or exp_data_id is null
order by 1 , 2]'
)
order by 2, 1]'
bulk collect into l_results
using a_exclude_xpath,a_include_xpath,
a_exclude_xpath,a_include_xpath,
Expand Down Expand Up @@ -359,7 +361,7 @@ create or replace package body ut_compound_data_helper is
if a_join_by_xpath is not null then
l_pk_xpath_tabs := ut_utils.string_to_table(a_join_by_xpath,'|');
l_column_filter := get_columns_row_filter(a_exclude_xpath, a_include_xpath);

execute immediate q'[
with xpaths_tab as (select column_value xpath from table(:xpath_tabs)),
expected_column_info as ( select :expected as item_data from dual ),
Expand Down Expand Up @@ -390,84 +392,7 @@ create or replace package body ut_compound_data_helper is

return l_no_missing_keys;
end;

function get_inclusion_matcher_sql(a_owner in varchar2) return varchar2 is
l_sql varchar2(32767);
begin
l_sql := 'with source_data as
( select t.data_id,t.item_hash,t.duplicate_no,
pk_hash
from ' || a_owner || '.ut_compound_data_tmp t
where data_id = :self_guid or data_id = :other_guid
)
select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no
from(
(
select t.item_hash,t. duplicate_no,t.pk_hash
from source_data t
where t.data_id = :self_guid
minus
select t.item_hash,t. duplicate_no,t.pk_hash
from source_data t
where t.data_id = :other_guid
)
union all
(
select t.item_hash,t. duplicate_no,t.pk_hash
from source_data t,
source_data s
where t.data_id = :other_guid
and s.data_id = :self_guid
and t.pk_hash = s.pk_hash
and t.item_hash != s.item_hash
)
)
tmp';
return l_sql;
end;

function get_not_inclusion_matcher_sql(a_owner in varchar2) return varchar2 is
l_sql varchar2(32767);
begin
/* Self set does not contain any values from other set */
l_sql := 'with source_data as
( select t.data_id,t.item_hash,t.duplicate_no,
pk_hash
from ' || a_owner || '.ut_compound_data_tmp t
where data_id = :self_guid or data_id = :other_guid
)
select distinct :diff_id,tmp.item_hash,tmp.pk_hash,tmp.duplicate_no
from
(
select act.item_hash,act. duplicate_no,act.pk_hash
from source_data act where act.data_id = :self_guid
and exists ( select 1
from source_data exp
where exp.data_id = :other_guid
and exp.item_hash = act.item_hash
)
union all
select null,null,null
from dual where :other_guid = :self_guid
)
tmp';
return l_sql;
end;

-- TODO:Rebuild as the unordered can be done using join_by compare
function get_refcursor_matcher_sql(a_owner in varchar2,a_inclusion_matcher boolean := false, a_negated_match boolean := false) return varchar2 is
l_sql varchar2(32767);
begin
l_sql := 'insert into ' || a_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no)'||chr(10);
if a_inclusion_matcher and not(a_negated_match) then
l_sql := l_sql || get_inclusion_matcher_sql(a_owner);
elsif a_inclusion_matcher and a_negated_match then
l_sql := l_sql || get_not_inclusion_matcher_sql(a_owner);
end if;

return l_sql;
end;


function generate_select_stmt(a_column_info ut_varchar2_list,a_xml_column_info xmltype) return clob is
l_sql_stmt clob;
l_col_type varchar2(4000);
Expand Down Expand Up @@ -570,19 +495,41 @@ create or replace package body ut_compound_data_helper is
for i in 1..a_column_info.count loop
l_sql_stmt := l_sql_stmt || case when l_sql_stmt is null then null else ' and ' end ||' a.'||a_column_info(i)||q'[ = ]'||' e.'||a_column_info(i);
end loop;

return l_sql_stmt;
end;

function generate_join_by_on_stmt (a_join_by_xpath_tab ut_varchar2_list) return clob is
function generate_join_by_on_stmt (a_join_by_xpath_tab ut_varchar2_list, a_columns_info xmltype, a_join_by_xpath in varchar2) return clob is
l_sql_stmt clob;
begin
for i in (with xpaths_tab as (select column_value xpath from table(a_join_by_xpath_tab))
select REGEXP_SUBSTR (xpath,'[^(/\*/)](.+)$') name
from xpaths_tab)
l_non_diff_var varchar2(32767);
l_ut_owner varchar2(250) := ut_utils.ut_owner;
begin
for i in (select /*+ CARDINALITY(xt 100) */
distinct
t.column_value,
xt.is_sql_diff
from
(select a_columns_info item_data from dual) x,
xmltable(
'/ROW/*'
passing x.item_data
columns
name varchar2(4000) PATH '@xml_valid_name',
is_sql_diff varchar2(4000) PATH '@sql_diffable'
) xt,
table(a_join_by_xpath_tab) t
where xt.name = t.column_value)
loop
l_sql_stmt := l_sql_stmt || case when l_sql_stmt is null then null else ' and ' end ||' a.'||i.name||q'[ = ]'||' e.'||i.name;

if i.is_sql_diff = 0 then
l_non_diff_var := l_ut_owner ||'.ut_compound_data_helper.get_hash((extract( a.'||i.column_value||','||a_join_by_xpath||')).getclobval()) = '
||l_ut_owner ||'.ut_compound_data_helper.get_hash((extract( e.'||i.column_value||','||a_join_by_xpath||')).getclobval())';
l_sql_stmt := l_sql_stmt || case when l_sql_stmt is null then null else ' and ' end ||' a.'||i.column_value||q'[ = ]'||' e.'||i.column_value;
elsif i.is_sql_diff = 1 then
l_sql_stmt := l_sql_stmt || case when l_sql_stmt is null then null else ' and ' end ||' a.'||i.column_value||q'[ = ]'||' e.'||i.column_value;
end if;

end loop;

return l_sql_stmt;
end;

Expand All @@ -605,7 +552,7 @@ create or replace package body ut_compound_data_helper is
end;

function gen_compare_sql(a_column_info xmltype, a_exclude_xpath varchar2,
a_include_xpath varchar2, a_join_by_xpath varchar2) return clob is
a_include_xpath varchar2, a_join_by_xpath varchar2, a_inclusion_type boolean, a_is_negated boolean ) return clob is
l_compare_sql clob;
l_temp_string varchar2(32767);

Expand All @@ -621,7 +568,7 @@ create or replace package body ut_compound_data_helper is
function get_columns_names (a_xpath_tab in ut_varchar2_list) return ut_varchar2_list is
l_names_tab ut_varchar2_list := ut_varchar2_list();
begin
select distinct REGEXP_SUBSTR (column_value,'[^(/\*/)](.+)$')
select distinct REGEXP_SUBSTR (column_value,'[^(\/*\/)]+',1,1)
bulk collect into l_names_tab
from table(a_xpath_tab);
return l_names_tab;
Expand All @@ -642,12 +589,23 @@ create or replace package body ut_compound_data_helper is
) xt;
return l_columns_info;
end;


function get_join_type(a_inclusion_compare in boolean,a_negated in boolean) return varchar2 is
begin
if a_inclusion_compare and not(a_negated) then
return ' right outer join ';
elsif a_inclusion_compare and a_negated then
return ' inner join ';
else
return ' full outer join ';
end if;
end;

begin
dbms_lob.createtemporary(l_compare_sql, true);

--TODO: Resolve issues with collection and nested tables, can we extract by internal column name if defined e.g. xml of colval.id.getclobval()
--Check include and exclude columns and create an actual column list that have to be compared.
--TODO :Reformat
if a_include_xpath is null and a_exclude_xpath is null then
l_act_col_tab := get_columns_info(a_column_info);
elsif a_include_xpath is not null and a_exclude_xpath is null then
Expand Down Expand Up @@ -697,28 +655,34 @@ create or replace package body ut_compound_data_helper is
-- If no key defined do the join on all columns
l_temp_string := ' select a.item_data as act_item_data, a.data_id act_data_id,'
||'e.item_data as exp_item_data, e.data_id exp_data_id, rownum item_no, nvl(e.dup_no,a.dup_no) dup_no '
||'from act a full outer join exp e on ( ';
||'from act a '||get_join_type(a_inclusion_type,a_is_negated)||' exp e on ( ';
ut_utils.append_to_clob(l_compare_sql,l_temp_string);
ut_utils.append_to_clob(l_compare_sql,generate_equal_sql(l_act_col_tab)||q'[ and e.dup_no = a.dup_no ) where a.data_id is null or e.data_id is null]');
ut_utils.append_to_clob(l_compare_sql,generate_equal_sql(l_act_col_tab)||q'[ and e.dup_no = a.dup_no ) where ]');
else
-- If key defined do the join or these and where on diffrences
l_temp_string := q'[ select a.item_data act_item_data, a.data_id act_data_id, ]'
||' e.item_data exp_item_data, e.data_id exp_data_id, rownum item_no,nvl(e.dup_no,a.dup_no) dup_no from act a full outer join exp e on ( e.dup_no = a.dup_no and ';
||' e.item_data exp_item_data, e.data_id exp_data_id, rownum item_no,nvl(e.dup_no,a.dup_no) dup_no from act a '||get_join_type(a_inclusion_type,a_is_negated)||' exp e on ( e.dup_no = a.dup_no and ';
ut_utils.append_to_clob(l_compare_sql,l_temp_string);

ut_utils.append_to_clob(l_compare_sql,generate_join_by_on_stmt (l_pk_xpath_tabs)||' ) ');
ut_utils.append_to_clob(l_compare_sql,generate_join_by_on_stmt (l_pk_xpath_tabs,a_column_info,a_join_by_xpath)||' ) where');

l_where_stmt := generate_not_equal_sql(l_act_col_tab, l_pk_xpath_tabs);
case
when l_where_stmt is null then
ut_utils.append_to_clob(l_compare_sql,' where a.data_id is null or e.data_id is null');
else
ut_utils.append_to_clob(l_compare_sql,' where ( '||l_where_stmt||' ) or ( a.data_id is null or e.data_id is null )');
end case;

if not a_is_negated then
l_where_stmt := generate_not_equal_sql(l_act_col_tab, l_pk_xpath_tabs);
if l_where_stmt is not null then
ut_utils.append_to_clob(l_compare_sql,' ( '||l_where_stmt||' ) or ');
end if;
end if;
end if;

--TEST
dbms_output.put_line( l_compare_sql);

--If its inlcusion we expect a actual set to fully match and have no extra elements over expected
if a_inclusion_type and not(a_is_negated) then
l_temp_string := ' ( a.data_id is null ) ';
else
l_temp_string := ' (a.data_id is null or e.data_id is null) ';
end if;
ut_utils.append_to_clob(l_compare_sql,l_temp_string);

return l_compare_sql;
end;

Expand Down
6 changes: 2 additions & 4 deletions source/expectations/data_values/ut_compound_data_helper.pks
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ create or replace package ut_compound_data_helper authid definer is

function is_pk_exists(a_expected_cursor xmltype, a_actual_cursor xmltype, a_exclude_xpath varchar2, a_include_xpath varchar2,a_join_by_xpath varchar2)
return tt_missing_pk;

function get_refcursor_matcher_sql(a_owner in varchar2,a_inclusion_matcher boolean := false, a_negated_match boolean := false) return varchar2;


function gen_compare_sql(a_column_info xmltype, a_exclude_xpath varchar2,
a_include_xpath varchar2, a_join_by_xpath varchar2) return clob;
a_include_xpath varchar2, a_join_by_xpath varchar2, a_inclusion_type boolean, a_is_negated boolean ) return clob;

procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw);

Expand Down
64 changes: 8 additions & 56 deletions source/expectations/data_values/ut_compound_data_value.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -234,58 +234,10 @@ create or replace type body ut_compound_data_value as
return l_result;
end;

member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2,
a_unordered boolean , a_inclusion_compare boolean := false, a_is_negated boolean := false ) return integer is
l_other ut_compound_data_value;
l_ut_owner varchar2(250) := ut_utils.ut_owner;
l_diff_id ut_compound_data_helper.t_hash;
l_result integer;
l_row_diffs ut_compound_data_helper.tt_row_diffs;
c_max_rows constant integer := 20;
l_sql varchar2(32767);

begin
if not a_other is of (ut_compound_data_value) then
raise value_error;
end if;

l_other := treat(a_other as ut_compound_data_value);

l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id);

/*!*
* Comparision is based on type of search, for inclusion based search we will look for left join only.
* For normal two side diff we will peform minus on two sets two get diffrences.
* SELF is expected.
* Due to growing complexity I have moved a dynamic SQL into helper package.
*/
l_sql := ut_compound_data_helper.get_refcursor_matcher_sql(l_ut_owner,a_inclusion_compare,a_is_negated);
member function compare_implementation(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2,
a_join_by_xpath varchar2,a_unordered boolean, a_inclusion_compare boolean := false, a_is_negated boolean := false ) return integer is

execute immediate l_sql
using self.data_id, l_other.data_id,
l_diff_id,
self.data_id, l_other.data_id,
l_other.data_id,self.data_id;

/*!*
* Result OK when is not inclusion matcher and both are the same
* Resullt OK when is inclusion matcher and left contains right set
*/
if sql%rowcount = 0 and self.elements_count = l_other.elements_count and not(a_inclusion_compare ) then
l_result := 0;
elsif sql%rowcount = 0 and a_inclusion_compare then
l_result := 0;
else
l_result := 1;
end if;
return l_result;
end;

member function compare_implementation_by_sql(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_inclusion_compare boolean := false) return integer is

l_actual ut_data_value_refcursor := treat(a_other as ut_data_value_refcursor);
l_diff_id ut_compound_data_helper.t_hash;

l_diff_id ut_compound_data_helper.t_hash;
l_other ut_compound_data_value;
l_result integer;
--We will start with number od differences being displayed.
Expand All @@ -299,16 +251,16 @@ create or replace type body ut_compound_data_value as
--TODO : Error on xml when same column is more then once in item data xml.Do we need to cleanup ??
l_other := treat(a_other as ut_compound_data_value);
l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_other.data_id);
open l_loop_curs for ut_compound_data_helper.gen_compare_sql(l_actual.columns_info, a_exclude_xpath,
a_include_xpath, a_join_by_xpath) using self.data_id,l_actual.data_id;

open l_loop_curs for ut_compound_data_helper.gen_compare_sql(treat(a_other as ut_data_value_refcursor).columns_info, a_exclude_xpath,
a_include_xpath, a_join_by_xpath, a_inclusion_compare, a_is_negated) using self.data_id,l_other.data_id;
loop
fetch l_loop_curs bulk collect into l_diff_tab limit l_max_rows;
exit when l_diff_tab.count = 0;
if (ut_utils.gc_diff_max_rows > l_sql_rowcount ) then
ut_compound_data_helper.insert_diffs_result(l_diff_tab,l_diff_id);
end if;

l_sql_rowcount := l_sql_rowcount + l_diff_tab.count;

if (ut_utils.gc_diff_max_rows <= l_sql_rowcount and l_max_rows != ut_utils.gc_bc_fetch_limit ) then
Expand All @@ -318,7 +270,7 @@ create or replace type body ut_compound_data_value as

ut_compound_data_helper.set_rows_diff(l_sql_rowcount);
--result is OK only if both are same
if l_sql_rowcount = 0 and self.elements_count = l_other.elements_count then
if l_sql_rowcount = 0 and ( self.elements_count = l_other.elements_count or a_inclusion_compare )then
l_result := 0;
else
l_result := 1;
Expand Down
Loading