From 39ff2ed0090a22fe680f5de38a2aa87f31b95226 Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Wed, 2 Apr 2025 20:41:46 +0100 Subject: [PATCH 1/3] Adding tests for issue 1293 --- .../expectations/test_expectations_cursor.pkb | 42 +++++++++++++++++++ .../expectations/test_expectations_cursor.pks | 6 +++ 2 files changed, 48 insertions(+) diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb index 847cce9a0..867a5f3db 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -2950,5 +2950,47 @@ Rows: [ 2 differences ] ); end; + procedure cursor_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 cursor_not_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); + --Assert + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); + end; + end; / diff --git a/test/ut3_user/expectations/test_expectations_cursor.pks b/test/ut3_user/expectations/test_expectations_cursor.pks index 0f34486a9..53f754322 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pks +++ b/test/ut3_user/expectations/test_expectations_cursor.pks @@ -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 cursor_joinby_compare_issue_1293; + + --%test( Compares cursors with duplicate rows - Issue #1293 ) + procedure cursor_not_joinby_compare_issue_1293; + end; / From 85734ffec7f57efff073d833ee2d43de1a9ad0f2 Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Thu, 3 Apr 2025 18:38:33 +0100 Subject: [PATCH 2/3] For a join by key we need to also compare by duplicate numbers to make sure that we have same amount of rows when rows are identical but row counts is different. --- source/expectations/data_values/ut_compound_data_helper.pkb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 4517cd43c..875ec760a 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -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 '); From 6f273df2752c7a0665debbc9532886ea01f8ff5a Mon Sep 17 00:00:00 2001 From: Lukasz Wasylow Date: Thu, 3 Apr 2025 19:49:58 +0100 Subject: [PATCH 3/3] Change procedure nameto be less 30 to work for 11 and 12 --- test/ut3_user/expectations/test_expectations_cursor.pkb | 4 ++-- test/ut3_user/expectations/test_expectations_cursor.pks | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb index 867a5f3db..a4ef4e8f2 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -2950,7 +2950,7 @@ Rows: [ 2 differences ] ); end; - procedure cursor_joinby_compare_issue_1293 is + procedure cr_joinby_compare_issue_1293 is l_actual sys_refcursor; l_expected sys_refcursor; begin @@ -2971,7 +2971,7 @@ Rows: [ 2 differences ] ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; - procedure cursor_not_joinby_compare_issue_1293 is + procedure cr_not_joinby_comp_issue_1293 is l_actual sys_refcursor; l_expected sys_refcursor; begin diff --git a/test/ut3_user/expectations/test_expectations_cursor.pks b/test/ut3_user/expectations/test_expectations_cursor.pks index 53f754322..8cceb5e01 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pks +++ b/test/ut3_user/expectations/test_expectations_cursor.pks @@ -486,10 +486,10 @@ create or replace package test_expectations_cursor is procedure multiple_cursor_expectations; --%test( Compares cursors with duplicate rows using join by - Issue #1293 ) - procedure cursor_joinby_compare_issue_1293; + procedure cr_joinby_compare_issue_1293; --%test( Compares cursors with duplicate rows - Issue #1293 ) - procedure cursor_not_joinby_compare_issue_1293; + procedure cr_not_joinby_comp_issue_1293; end; /