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
Further deprecation of Xpath
  • Loading branch information
lwasylow committed Nov 20, 2018
commit 6cb5fe7d629889185ff3fae6db44040b912080d2
137 changes: 63 additions & 74 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -85,81 +85,45 @@ create or replace package body ut_compound_data_helper is
end if;
return l_filter;
end;

function get_columns_diff(
a_expected xmltype, a_actual xmltype, a_exclude_xpath varchar2, a_include_xpath varchar2
) return tt_column_diffs is

function get_columns_diff(a_expected ut_cursor_column_tab, a_actual ut_cursor_column_tab)
return tt_column_diffs is
l_column_filter varchar2(32767);
l_sql varchar2(32767);
l_results tt_column_diffs;
begin
l_column_filter := get_columns_row_filter(a_exclude_xpath, a_include_xpath);
--CARDINALITY hints added to address issue: https://github.com/utPLSQL/utPLSQL/issues/752
l_sql := q'[
with
expected_cols as ( select :a_expected as item_data from dual ),
actual_cols as ( select :a_actual as item_data from dual ),
expected_cols_info as (
select e.*,
replace(expected_type,'VARCHAR2','CHAR') expected_type_compare
from (
select /*+ CARDINALITY(xt 100) */
rownum expected_pos,
xt.name expected_name,
xt.type expected_type
from (select ]'||l_column_filter||q'[ from expected_cols ucd) x,
xmltable(
'/ROW/*'
passing x.item_data
columns
name varchar2(4000) PATH '@xml_valid_name',
type varchar2(4000) PATH '/'
) xt
) e
),
actual_cols_info as (
select a.*,
replace(actual_type,'VARCHAR2','CHAR') actual_type_compare
from (select /*+ CARDINALITY(xt 100) */
rownum actual_pos,
xt.name actual_name,
xt.type actual_type
from (select ]'||l_column_filter||q'[ from actual_cols ucd) x,
xmltable('/ROW/*'
passing x.item_data
columns
name varchar2(4000) path '@xml_valid_name',
type varchar2(4000) path '/'
) xt
) a
),
joined_cols as (
select e.*, a.*,
row_number() over(partition by case when actual_pos + expected_pos is not null then 1 end order by actual_pos) a_pos_nn,
row_number() over(partition by case when actual_pos + expected_pos is not null then 1 end order by expected_pos) e_pos_nn
from expected_cols_info e
full outer join actual_cols_info a on e.expected_name = a.actual_name
)
with
expected_cols as
(select access_path exp_column_name,column_position exp_col_pos,
replace(column_type,'VARCHAR2','CHAR') exp_col_type_compare, column_type exp_col_type
from table(a_expected)),
actual_cols as
(select access_path act_column_name,column_position act_col_pos,
replace(column_type,'VARCHAR2','CHAR') act_col_type_compare, column_type act_col_type
from table(a_actual)),
joined_cols as
(select e.*,a.*,
row_number() over(partition by case when a.act_col_pos + e.exp_col_pos is not null then 1 end order by a.act_col_pos) a_pos_nn,
row_number() over(partition by case when a.act_col_pos + e.exp_col_pos is not null then 1 end order by e.exp_col_pos) e_pos_nn
from expected_cols e
full outer join actual_cols a on e.exp_column_name = a.act_column_name)
select case
when expected_pos is null and actual_pos is not null then '+'
when expected_pos is not null and actual_pos is null then '-'
when expected_type_compare != actual_type_compare then 't'
when exp_col_pos is null and act_col_pos is not null then '+'
when exp_col_pos is not null and act_col_pos is null then '-'
when exp_col_type_compare != act_col_type_compare then 't'
else 'p'
end as diff_type,
expected_name, expected_type, expected_pos,
actual_name, actual_type, actual_pos
exp_column_name, exp_col_type, exp_col_pos,
act_column_name, act_col_type, act_col_pos
bulk collect into l_results
from joined_cols
--column is unexpected (extra) or missing
where actual_pos is null or expected_pos is null
where act_col_pos is null or exp_col_pos is null
--column type is not matching (except CHAR/VARCHAR2)
or actual_type_compare != expected_type_compare
or act_col_type_compare != exp_col_type_compare
--column position is not matching (both when excluded extra/missing columns as well as when they are included)
or (a_pos_nn != e_pos_nn and expected_pos != actual_pos)
order by expected_pos, actual_pos]';
execute immediate l_sql
bulk collect into l_results
using a_expected, a_actual, a_exclude_xpath, a_include_xpath, a_exclude_xpath, a_include_xpath;

or (a_pos_nn != e_pos_nn and exp_col_pos != act_col_pos)
order by exp_col_pos, act_col_pos;
return l_results;
end;

Expand Down Expand Up @@ -690,6 +654,7 @@ create or replace package body ut_compound_data_helper is
end if;
ut_utils.append_to_clob(l_compare_sql,l_temp_string);

dbms_output.put_line(l_compare_sql);
return l_compare_sql;
end;

Expand Down Expand Up @@ -735,12 +700,8 @@ create or replace package body ut_compound_data_helper is
select lev,column_name,parent_name from hier),
t1(column_name, parent_name) AS (
select column_name,parent_name from table(:a_cursor_info) where parent_name is null
union all
select t2.column_name,t2.parent_name from table(:a_cursor_info) t2, t1 where t2.parent_name = t1.column_name)
select ut_cursor_column(i.column_name,i.column_schema,i.column_type_name, i.column_prec,i.column_scale,i.column_len, i.parent_name,
i.hierarchy_level,i.column_position, i.column_type)
from t1 join table(:a_cursor_info) i on ( nvl(t1.parent_name,1) = nvl(i.parent_name,1) and t1.column_name = i.column_name)
]';
union all
select t2.column_name,t2.parent_name from table(:a_cursor_info) t2, t1 where t2.parent_name = t1.column_name)]';
begin
return l_sql;
end;
Expand All @@ -750,10 +711,13 @@ create or replace package body ut_compound_data_helper is
l_sql varchar2(32767) := get_cursor_vs_list_sql;
l_result ut_cursor_column_tab := ut_cursor_column_tab();
begin
l_sql := l_sql || q'[select ut_cursor_column(i.column_name,i.column_schema,i.column_type_name, i.column_prec,i.column_scale,i.column_len, i.parent_name,
i.hierarchy_level,i.column_position, i.column_type)
from t1 join table(:a_cursor_info) i on ( nvl(t1.parent_name,1) = nvl(i.parent_name,1) and t1.column_name = i.column_name)]';
if a_include then
l_sql := l_sql || ' join constructed c on ( nvl(t1.parent_name,1) = nvl(c.parent_name,1) and t1.column_name = c.column_name)';
else
l_sql := l_sql ||'left outer join constructed c on ( nvl(t1.parent_name,1) = nvl(c.parent_name,1) and t1.column_name = c.column_name)
l_sql := l_sql ||' left outer join constructed c on ( nvl(t1.parent_name,1) = nvl(c.parent_name,1) and t1.column_name = c.column_name)
where c.column_name is null';
end if;

Expand All @@ -764,18 +728,35 @@ create or replace package body ut_compound_data_helper is
end;

function compare_cursor_to_columns(a_cursor_info ut_cursor_column_tab, a_current_list ut_varchar2_list)
return ut_cursor_column_tab is
return ut_varchar2_list is
l_sql varchar2(32767) := get_cursor_vs_list_sql;
l_result ut_cursor_column_tab := ut_cursor_column_tab();
l_result ut_varchar2_list := ut_varchar2_list();
begin
l_sql := l_sql || q'[select c.parent_name || case when c.parent_name is null then null else '/' end ||c.column_name
from t1 join table(:a_cursor_info) i on ( nvl(t1.parent_name,1) = nvl(i.parent_name,1) and t1.column_name = i.column_name)]';
l_sql := l_sql ||'right outer join constructed c on ( nvl(t1.parent_name,1) = nvl(c.parent_name,1) and t1.column_name = c.column_name)
where t1.column_name is null';

execute immediate l_sql bulk collect into l_result
using a_current_list,a_cursor_info,a_cursor_info,a_cursor_info;
return l_result;
end;


function get_missing_pk(a_expected ut_cursor_column_tab, a_actual ut_cursor_column_tab, a_current_list ut_varchar2_list)
return tt_missing_pk is
l_actual ut_varchar2_list := coalesce(compare_cursor_to_columns(a_actual,a_current_list),ut_varchar2_list());
l_expected ut_varchar2_list := coalesce(compare_cursor_to_columns(a_expected,a_current_list),ut_varchar2_list());
l_missing_pk tt_missing_pk;
begin
select name,type
bulk collect into l_missing_pk
from
(select act.column_value name, 'e' type from table(l_expected) act
union all
select exp.column_value name, 'a' type from table(l_actual) exp)
order by type desc,name;
return l_missing_pk;
end;

function inc_exc_columns_from_cursor (a_cursor_info ut_cursor_column_tab, a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list)
return ut_cursor_column_tab is
Expand Down Expand Up @@ -819,5 +800,13 @@ create or replace package body ut_compound_data_helper is
return l_result;
end;

function contains_collection (a_cursor_info ut_cursor_column_tab) return number is
l_collection_elements number;
begin
select count(1) into l_collection_elements from
table(a_cursor_info) c where c.is_collection = 1;
return l_collection_elements;
end;

end;
/
12 changes: 8 additions & 4 deletions source/expectations/data_values/ut_compound_data_helper.pks
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ create or replace package ut_compound_data_helper authid definer is
a_table_alias varchar2 := 'ucd', a_column_alias varchar2 := 'item_data'
) return varchar2;

function get_columns_diff(
a_expected xmltype, a_actual xmltype, a_exclude_xpath varchar2, a_include_xpath varchar2
) return tt_column_diffs;
function get_columns_diff(a_expected ut_cursor_column_tab, a_actual ut_cursor_column_tab)
return tt_column_diffs;

function get_pk_value (a_join_by_xpath varchar2,a_item_data xmltype) return clob;

Expand Down Expand Up @@ -107,10 +106,15 @@ create or replace package ut_compound_data_helper authid definer is
return ut_cursor_column_tab;

function compare_cursor_to_columns(a_cursor_info ut_cursor_column_tab, a_current_list ut_varchar2_list)
return ut_cursor_column_tab;
return ut_varchar2_list;

function get_missing_pk(a_expected ut_cursor_column_tab, a_actual ut_cursor_column_tab, a_current_list ut_varchar2_list)
return tt_missing_pk;

function inc_exc_columns_from_cursor (a_cursor_info ut_cursor_column_tab, a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list)
return ut_cursor_column_tab;

function contains_collection (a_cursor_info ut_cursor_column_tab) return number;

end;
/
8 changes: 5 additions & 3 deletions source/expectations/data_values/ut_compound_data_value.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ create or replace type body ut_compound_data_value as
return l_result_string;
end;

-- TODO : Rework to exclude xpath
Comment thread
jgebal marked this conversation as resolved.
Outdated
member function get_data_diff(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2,
a_join_by_xpath varchar2, a_unordered boolean) return clob is
c_max_rows integer := ut_utils.gc_diff_max_rows;
Expand Down Expand Up @@ -128,15 +129,16 @@ create or replace type body ut_compound_data_value as
l_message := chr(10)
||'Rows: [ ' || l_diff_row_count ||' differences'
|| case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end
||' ]' || chr(10)
|| case when l_row_diffs.count = 0
then ' All rows are different as the columns are not matching.' end;
||' ]'||chr(10)|| case when l_row_diffs.count = 0 then ' All rows are different as the columns are not matching.' else null end;
ut_utils.append_to_clob( l_result, l_message );
for i in 1 .. l_row_diffs.count loop
l_results.extend;
l_results(l_results.last) := get_diff_message(l_row_diffs(i),a_unordered);
end loop;
ut_utils.append_to_clob(l_result,l_results);
else
l_message:= chr(10)||'Rows: [ all different ]'||chr(10)||' All rows are different as the columns are not matching.';
ut_utils.append_to_clob( l_result, l_message );
end if;
return l_result;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ create or replace package body ut_curr_usr_compound_helper is
--clob/blob/xmltype/object/nestedcursor/nestedtable
if a_type_name IN (g_type_name_map(dbms_sql.blob_type),
g_type_name_map(dbms_sql.clob_type),
g_type_name_map(dbms_sql.bfile_type))
g_type_name_map(dbms_sql.bfile_type),
g_anytype_name_map(dbms_types.typecode_namedcollection))
then
return false;
else
Expand Down
5 changes: 5 additions & 0 deletions source/expectations/data_values/ut_cursor_column.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ create or replace type body ut_cursor_column as
self.has_nested_col := case when lower(self.column_type) = 'user_defined_type' and self.is_collection = 0 then 1 else 0 end;
end;

--TODO : Scenarios :
--namedcollection xmltype getclobhash
--collection xml type get clob hash
-- user defined type

constructor function ut_cursor_column( self in out nocopy ut_cursor_column,
a_col_name varchar2, a_col_schema_name varchar2,
a_col_type_name varchar2, a_col_prec integer, a_col_scale integer,
Expand Down
40 changes: 18 additions & 22 deletions source/expectations/data_values/ut_data_value_refcursor.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,17 @@ create or replace type body ut_data_value_refcursor as
return l_result_string;
end;

overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2 is
member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2,
a_unordered boolean := false, a_join_by_list ut_varchar2_list:=ut_varchar2_list() ) return varchar2 is
l_result clob;
l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab();
l_result_string varchar2(32767);
l_actual ut_data_value_refcursor;
l_column_diffs ut_compound_data_helper.tt_column_diffs := ut_compound_data_helper.tt_column_diffs();
l_exclude_xpath varchar2(32767) := a_exclude_xpath;

l_missing_pk ut_compound_data_helper.tt_missing_pk := ut_compound_data_helper.tt_missing_pk();
l_col_diffs ut_compound_data_helper.tt_column_diffs := ut_compound_data_helper.tt_column_diffs();

function get_col_diff_text(a_col ut_compound_data_helper.t_column_diffs) return varchar2 is
begin
Expand All @@ -143,7 +146,6 @@ create or replace type body ut_data_value_refcursor as
function get_missing_key_message(a_missing_keys ut_compound_data_helper.t_missing_pk) return varchar2 is
l_message varchar2(200);
begin

if a_missing_keys.diff_type = 'a' then
l_message := ' Join key '||a_missing_keys.missingxpath||' does not exists in actual';
elsif a_missing_keys.diff_type = 'e' then
Expand Down Expand Up @@ -184,7 +186,7 @@ create or replace type body ut_data_value_refcursor as

--diff columns
if not self.is_null and not l_actual.is_null then
l_column_diffs := ut_compound_data_helper.get_columns_diff(self.columns_info, l_actual.columns_info, a_exclude_xpath, a_include_xpath);
l_column_diffs := ut_compound_data_helper.get_columns_diff(self.cursor_details.cursor_info,l_actual.cursor_details.cursor_info);

if l_column_diffs.count > 0 then
ut_utils.append_to_clob(l_result,chr(10) || 'Columns:' || chr(10));
Expand All @@ -199,8 +201,8 @@ create or replace type body ut_data_value_refcursor as
end if;

--check for missing pk
if (a_join_by_xpath is not null) then
l_missing_pk := ut_compound_data_helper.is_pk_exists(self.key_info, l_actual.key_info, a_exclude_xpath, a_include_xpath,a_join_by_xpath);
if a_join_by_list.count > 0 then
l_missing_pk := ut_compound_data_helper.get_missing_pk(self.cursor_details.cursor_info,l_actual.cursor_details.cursor_info,a_join_by_list);
end if;

--diff rows and row elements if the pk is not missing
Expand All @@ -213,7 +215,8 @@ create or replace type body ut_data_value_refcursor as
ut_utils.append_to_clob(l_result, get_missing_key_message(l_missing_pk(i))|| chr(10));
end loop;

if ut_utils.int_to_boolean(self.contain_collection) or ut_utils.int_to_boolean(l_actual.contain_collection) then
if ut_compound_data_helper.contains_collection(self.cursor_details.cursor_info) > 0
or ut_compound_data_helper.contains_collection(l_actual.cursor_details.cursor_info) > 0 then
ut_utils.append_to_clob(l_result,' Please make sure that your join clause is not refferring to collection element'|| chr(10));
end if;

Expand All @@ -228,36 +231,29 @@ create or replace type body ut_data_value_refcursor as
a_is_negated boolean := false, a_join_by_list ut_varchar2_list:=ut_varchar2_list())
return integer is
l_result integer := 0;
l_other ut_data_value_refcursor;

l_act_pk ut_cursor_column_tab;
l_exp_pk ut_cursor_column_tab;
l_actual ut_data_value_refcursor;

l_pk_missing_tab ut_compound_data_helper.tt_missing_pk;

function is_pk_missing (a_pk_missing_tab ut_compound_data_helper.tt_missing_pk) return integer is
begin
return case when a_pk_missing_tab.count > 0 then 1 else 0 end;
end;
begin
if not a_other is of (ut_data_value_refcursor) then
raise value_error;
end if;

l_other := treat(a_other as ut_data_value_refcursor);
l_actual := treat(a_other as ut_data_value_refcursor);

--if we join by key and key is missing fail and report error
if a_join_by_list.count > 0 then
l_act_pk := ut_compound_data_helper.compare_cursor_to_columns(self.cursor_details.cursor_info ,a_join_by_list);
l_exp_pk := ut_compound_data_helper.compare_cursor_to_columns(l_other.cursor_details.cursor_info,a_join_by_list);
l_result := case when (l_act_pk.count > 0) or (l_exp_pk.count > 0) then 1 else 0 end;
l_pk_missing_tab := ut_compound_data_helper.get_missing_pk(self.cursor_details.cursor_info,l_actual.cursor_details.cursor_info,a_join_by_list);
l_result := case when (l_pk_missing_tab.count > 0) then 1 else 0 end;
end if;


if l_result = 0 then
if (self.cursor_details is not null and l_other.cursor_details is not null) and (self.cursor_details != l_other.cursor_details) then
if (self.cursor_details is not null and l_actual.cursor_details is not null) and (self.cursor_details != l_actual.cursor_details) then
l_result := 1;
end if;
end if;
l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other,a_unordered, a_inclusion_compare,
a_is_negated, a_join_by_list);
a_is_negated, a_join_by_list);
end if;

return l_result;
Expand Down
Loading