Skip to content

Enable duplicate detection on cursor comparison using join by #1295

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 3 commits into from
Apr 3, 2025
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
4 changes: 2 additions & 2 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ create or replace package body ut_compound_data_helper is
ut_utils.append_to_clob(a_partition_stmt,' row_number() over (partition by '||l_partition_tmp||' order by '||l_partition_tmp||' ) ');

if a_pk_table.count > 0 then
-- If key defined do the join or these and where on diffrences
a_join_by_stmt := ut_utils.table_to_clob(l_join_by_list, ' and ');
-- If key defined do the join or these and where on diffrences as well as on duplicate number when rows are same.
a_join_by_stmt := ' e."UT3$_Dup#No" = a."UT3$_Dup#No" and '||ut_utils.table_to_clob(l_join_by_list, ' and ');
elsif a_unordered then
-- If no key defined do the join on all columns
a_join_by_stmt := ' e."UT3$_Dup#No" = a."UT3$_Dup#No" and '||ut_utils.table_to_clob(l_equal_list, ' and ');
Expand Down
42 changes: 42 additions & 0 deletions test/ut3_user/expectations/test_expectations_cursor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -2950,5 +2950,47 @@ Rows: [ 2 differences ]
);
end;

procedure cr_joinby_compare_issue_1293 is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
--Arrange
open l_expected for
select 'FOO' username, 12 from dual union all
select 'TEST' username, -600 user_id from dual
order by 1 desc;
open l_actual for
select 'FOO' username, 12 from dual union all
select 'TEST' username, -600 user_id from dual union all
-- DUPLICATE!!!
select 'TEST' username, -600 user_id from dual
order by 1 asc;
--Act
ut3_develop.ut.expect(l_actual).to_equal(l_expected).join_by('USERNAME');
--Assert
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

procedure cr_not_joinby_comp_issue_1293 is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
--Arrange
open l_expected for
select 'FOO' username, 12 from dual union all
select 'TEST' username, -600 user_id from dual
order by 1 desc;
open l_actual for
select 'FOO' username, 12 from dual union all
select 'TEST' username, -600 user_id from dual union all
-- DUPLICATE!!!
select 'TEST' username, -600 user_id from dual
order by 1 asc;
--Act
ut3_develop.ut.expect(l_actual).to_equal(l_expected);
--Assert
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

end;
/
6 changes: 6 additions & 0 deletions test/ut3_user/expectations/test_expectations_cursor.pks
Original file line number Diff line number Diff line change
Expand Up @@ -485,5 +485,11 @@ create or replace package test_expectations_cursor is
--%test( Multiple failures reported correctly - Issue #998 )
procedure multiple_cursor_expectations;

--%test( Compares cursors with duplicate rows using join by - Issue #1293 )
procedure cr_joinby_compare_issue_1293;

--%test( Compares cursors with duplicate rows - Issue #1293 )
procedure cr_not_joinby_comp_issue_1293;

end;
/
Loading