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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,7 @@ create or replace package body ut_compound_data_helper is
/**
* Since its unordered search we cannot select max rows from diffs as we miss some comparision records
* We will restrict output on higher level of select
*/

*/
execute immediate q'[with
diff_info as (select item_hash,duplicate_no from ut_compound_data_diff_tmp ucdc where diff_id = :diff_guid)
select duplicate_no,
Expand Down Expand Up @@ -403,6 +402,7 @@ create or replace package body ut_compound_data_helper is
diff_info i
where ucd.data_id = :self_guid
and ucd.item_hash = i.item_hash
and ucd.duplicate_no = i.duplicate_no
) r,
table( xmlsequence( extract(r.item_data,'/*') ) ) ucd
) ucd
Expand All @@ -417,6 +417,7 @@ create or replace package body ut_compound_data_helper is
diff_info i
where ucd.data_id = :other_guid
and ucd.item_hash = i.item_hash
and ucd.duplicate_no = i.duplicate_no
) r,
table( xmlsequence( extract(r.item_data,'/*') ) ) ucd
) ucd
Expand Down
23 changes: 16 additions & 7 deletions source/expectations/data_values/ut_compound_data_value.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ create or replace type body ut_compound_data_value as
**/
execute immediate 'merge into ' || l_ut_owner || '.ut_compound_data_tmp tgt
using (
select ucd_out.item_hash,
ucd_out.pk_hash,
ucd_out.item_no,
ucd_out.data_id,
row_number() over (partition by ucd_out.pk_hash,ucd_out.item_hash,ucd_out.data_id order by 1,2) duplicate_no
from
(
select '||l_ut_owner ||'.ut_compound_data_helper.get_hash(ucd.item_data.getclobval()) item_hash,
pk_hash, ucd.item_no, ucd.data_id
from
Expand All @@ -242,47 +249,49 @@ create or replace type body ut_compound_data_value as
from ' || l_ut_owner || q'[.ut_compound_data_tmp ucd
where data_id = :self_guid or data_id = :other_guid
) ucd
)ucd_out
) src
on (tgt.item_no = src.item_no and tgt.data_id = src.data_id)
when matched then update
set tgt.item_hash = src.item_hash,
tgt.pk_hash = src.pk_hash ]'
tgt.pk_hash = src.pk_hash,
tgt.duplicate_no = src.duplicate_no]'
using a_exclude_xpath, a_include_xpath,a_join_by_xpath,self.data_id, l_other.data_id;

/* Peform minus on two sets two get diffrences that will be used later on to print results */
execute immediate 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp ( diff_id,item_hash,pk_hash,duplicate_no)
with source_data as
( select t.data_id,t.item_hash,row_number() over (partition by t.pk_hash,t.item_hash,t.data_id order by 1,2) duplicate_no,
( select t.data_id,t.item_hash,t.duplicate_no,
pk_hash
from ' || l_ut_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
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
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
select t.item_hash,t.duplicate_no,t.pk_hash
from source_data t
where t.data_id = :other_guid
minus
select t.item_hash,t. duplicate_no,t.pk_hash
select t.item_hash,t.duplicate_no,t.pk_hash
from source_data t
where t.data_id = :self_guid
))tmp'
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 is OK only if both are same
--result is OK only if both are same
if sql%rowcount = 0 and self.elements_count = l_other.elements_count then
l_result := 0;
else
Expand Down
34 changes: 33 additions & 1 deletion test/core/expectations/test_expectations_cursor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,38 @@ Diff:%
ut.expect(l_actual_message).to_be_like(l_expected_message);

end;


procedure unordered_fix_764 is
l_actual sys_refcursor;
l_expected sys_refcursor;
l_expected_message varchar2(32767);
l_actual_message varchar2(32767);
begin
open l_expected for
select 'Table' as name from dual
union all
select 'Desk' as name from dual
union all
select 'Table' as name from dual;

open l_actual for
select 'Desk' as name from dual
union all
select 'Table' as name from dual;

--Assert
ut3.ut.expect( l_actual ).to_equal( l_expected ).unordered();

--Assert
l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]
%Diff:
%Rows: [ 1 differences ]
%Missing: <ROW><NAME>Table</NAME></ROW>%]';
l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
--Assert
ut.expect(l_actual_message).to_be_like(l_expected_message);

end;

end;
/
5 changes: 4 additions & 1 deletion test/core/expectations/test_expectations_cursor.pks
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ create or replace package test_expectations_cursor is

--%test(Trying to join on collection element inside record )
procedure compare_rec_coll_as_join;


--%test( Unordered fix for issues with duplicate no : #764 )
procedure unordered_fix_764;

end;
/