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

Skip to content

Commit ab55d12

Browse files
committed
fixing issue with order of data.
instead of rownum force order from cardinality of xml. fix error when raising for all the valid range for user-specified error numbers is -20000 to -20999 inclusively.
1 parent 6306af6 commit ab55d12

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

source/core/ut_utils.pks

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ create or replace package ut_utils authid definer is
118118
gc_failure_for_all constant pls_integer := -24381;
119119
pragma exception_init (ex_failure_for_all, -24381);
120120

121+
ex_dml_for_all exception;
122+
gc_dml_for_all constant pls_integer := -20215;
123+
pragma exception_init (ex_dml_for_all, -20215);
124+
121125
gc_max_storage_varchar2_len constant integer := 4000;
122126
gc_max_output_string_length constant integer := 4000;
123127
gc_max_input_string_length constant integer := gc_max_output_string_length - 2; --we need to remove 2 chars for quotes around string

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ create or replace package body ut_compound_data_helper is
3131
select
3232
ucd.item_data
3333
,x.data_id data_id
34-
,{:item_no:} item_no
34+
,position + x.item_no item_no
3535
{:columns:}
3636
from {:ut3_owner:}.ut_compound_data_tmp x,
3737
xmltable('/ROWSET/ROW' passing x.item_data columns
@@ -49,7 +49,7 @@ create or replace package body ut_compound_data_helper is
4949
select
5050
ucd.item_data
5151
,x.data_id data_id
52-
,{:item_no:} item_no
52+
,position + x.item_no item_no
5353
{:columns:}
5454
from {:ut3_owner:}.ut_compound_data_tmp x,
5555
xmltable('/ROWSET/ROW' passing x.item_data columns
@@ -64,7 +64,7 @@ create or replace package body ut_compound_data_helper is
6464
a.data_id act_data_id,
6565
e.item_data as exp_item_data,
6666
e.data_id exp_data_id,
67-
{:item_no_select:} as item_no,
67+
{:item_no:} as item_no,
6868
nvl(e.dup_no,a.dup_no) dup_no
6969
from act a {:join_type:} exp e on ( {:join_condition:} )
7070
where {:where_condition:}]';
@@ -354,8 +354,8 @@ create or replace package body ut_compound_data_helper is
354354
begin
355355
return
356356
case
357-
when not a_unordered then 'position + x.item_no '
358-
else 'rownum '
357+
when a_unordered then 'row_number() over ( order by nvl(e.item_no,a.item_no))'
358+
else 'nvl(e.item_no,a.item_no) '
359359
end;
360360
end;
361361

@@ -372,10 +372,9 @@ create or replace package body ut_compound_data_helper is
372372

373373
l_compare_sql := replace(l_compare_sql,'{:duplicate_number:}',l_partition_stmt);
374374
l_compare_sql := replace(l_compare_sql,'{:columns:}',l_select_stmt);
375-
l_compare_sql := replace(l_compare_sql,'{:item_no:}',get_item_no(a_unordered));
376375
l_compare_sql := replace(l_compare_sql,'{:ut3_owner:}',l_ut_owner);
377376
l_compare_sql := replace(l_compare_sql,'{:xml_to_columns:}',l_xmltable_stmt);
378-
l_compare_sql := replace(l_compare_sql,'{:item_no_select:}',case when a_unordered then 'rownum' else 'nvl(e.item_no,a.item_no)' end);
377+
l_compare_sql := replace(l_compare_sql,'{:item_no:}',get_item_no(a_unordered));
379378
l_compare_sql := replace(l_compare_sql,'{:join_type:}',get_join_type(a_inclusion_type,a_is_negated));
380379
l_compare_sql := replace(l_compare_sql,'{:join_condition:}',l_join_on_stmt);
381380

@@ -634,7 +633,7 @@ create or replace package body ut_compound_data_helper is
634633
a_diff_tab(idx).item_no, a_diff_tab(idx).dup_no);
635634
exception
636635
when ut_utils.ex_failure_for_all then
637-
raise_application_error(ut_utils.gc_failure_for_all,'Failure to insert a diff tmp data.');
636+
raise_application_error(ut_utils.gc_dml_for_all,'Failure to insert a diff tmp data.');
638637
end;
639638

640639
procedure set_rows_diff(a_rows_diff integer) is

test/core/expectations/test_expectations_cursor.pkb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,11 +1632,11 @@ Diff:%
16321632
l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 3 ]%
16331633
Diff:%
16341634
Rows: [ 5 differences%
1635-
%Extra: <COLVAL><ID>2</ID><name>Something 2</name><Value>2</Value></COLVAL>%
16361635
%Extra: <COLVAL><ID>1</ID><name>Something 1</name><Value>1</Value></COLVAL>%
1637-
%Missing: <COLVAL><ID>1</ID><name>Somethings 1</name><Value>1</Value></COLVAL>%
1636+
%Extra: <COLVAL><ID>2</ID><name>Something 2</name><Value>2</Value></COLVAL>%
1637+
%Missing: <COLVAL><ID>3</ID><name>Somethings 3</name><Value>3</Value></COLVAL>%
16381638
%Missing: <COLVAL><ID>2</ID><name>Somethings 2</name><Value>2</Value></COLVAL>%
1639-
%Missing: <COLVAL><ID>3</ID><name>Somethings 3</name><Value>3</Value></COLVAL>%]';
1639+
%Missing: <COLVAL><ID>1</ID><name>Somethings 1</name><Value>1</Value></COLVAL>%]';
16401640
l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
16411641
--Assert
16421642
ut.expect(l_actual_message).to_be_like(l_expected_message);
@@ -1914,11 +1914,11 @@ Diff:%
19141914
l_expected_message varchar2(32767);
19151915
l_actual_message varchar2(32767);
19161916
begin
1917-
select ut3.ut_key_value_pair(rownum,'Something '||rownum)
1917+
select ut3.ut_key_value_pair(rownum,'Apples '||rownum)
19181918
bulk collect into l_actual_tab
19191919
from dual connect by level <=2;
19201920

1921-
select ut3.ut_key_value_pair(rownum,'Somethings '||rownum)
1921+
select ut3.ut_key_value_pair(rownum,'Peaches '||rownum)
19221922
bulk collect into l_expected_tab
19231923
from dual connect by level <=2;
19241924

@@ -1936,10 +1936,10 @@ Diff:%
19361936
l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to equal: refcursor [ count = 2 ]
19371937
%Diff:
19381938
%Rows: [ 4 differences ]
1939-
%Extra: <RN>2</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Something 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Something 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>
1940-
%Extra: <RN>1</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Something 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Something 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>
1941-
%Missing: <RN>1</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Somethings 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Somethings 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>
1942-
%Missing: <RN>2</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Somethings 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Somethings 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>%]';
1939+
%Extra: <RN>1</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Apples 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Apples 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>
1940+
%Extra: <RN>2</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Apples 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Apples 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>
1941+
%Missing: <RN>1</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Peaches 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Peaches 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>
1942+
%Missing: <RN>2</RN><NESTED_TABLE><UT_KEY_VALUE_PAIR><KEY>1</KEY><VALUE>Peaches 1</VALUE></UT_KEY_VALUE_PAIR><UT_KEY_VALUE_PAIR><KEY>2</KEY><VALUE>Peaches 2</VALUE></UT_KEY_VALUE_PAIR></NESTED_TABLE>%]';
19431943
l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
19441944
--Assert
19451945
ut.expect(l_actual_message).to_be_like(l_expected_message);

0 commit comments

Comments
 (0)