Repository navigation
Closed
Description
When reporting differences in collections of base datatypes ( number, varchar2 ) the different rows are not reported the system only says:
Rows: [ 1 differences ]
All rows are different as the columns are not matchin
It looks like it is getting confused by the fact that the rows are not object.
When reporting differences in collections of object types the different rows will be reported:
Rows: [ 1 differences ]
Row No. 2 - Actual: <ID>3</ID>
Row No. 2 - Expected: <ID>2</ID>
I tried taking a look at the code that decides that the the rows are of different type, but I'm not familiar enough with the methods used to figure it out.
Here is a test case
create or replace type num_list is varray(14) of number;
/
create or replace type str_list is varray(14) of varchar2(100);
/
create or replace type t_obj as object(ID number);
/
create or replace type obj_list as varray(14) of t_obj;
/
create or replace package test_collections as
--%suite(compare collection types)
--%test(equal num_lists)
procedure equal_num_lists;
--%test(not equal num_lists)
procedure not_equal_num_lists;
--%test(equal str_lists)
procedure equal_str_lists;
--%test(not equal str_lists)
procedure not_equal_str_lists;
--%test(equal obj_lists)
procedure equal_obj_lists;
--%test(not equal obj_lists)
procedure not_equal_obj_lists;
end test_collections;
/
create or replace package body test_collections as
nl_expected num_list := num_list(1,2,3);
sl_expected str_list := str_list('A','B','C');
ol_expected obj_list := obj_list(t_obj(1),t_obj(2),t_obj(3));
procedure equal_num_lists is
begin
ut.expect( anydata.convertCollection(num_list(1,2,3)) ).to_equal(anydata.convertCollection(nl_expected) );
end;
procedure not_equal_num_lists is
begin
ut.expect( anydata.convertCollection(num_list(1,3,3)) ).to_equal(anydata.convertCollection(nl_expected) );
end;
procedure equal_str_lists is
begin
ut.expect( anydata.convertCollection(str_list('A','B','C')) ).to_equal(anydata.convertCollection(sl_expected) );
end;
procedure not_equal_str_lists is
begin
ut.expect( anydata.convertCollection(str_list('A','C','C')) ).to_equal(anydata.convertCollection(sl_expected) );
end;
procedure equal_obj_lists is
begin
ut.expect( anydata.convertCollection(obj_list(t_obj(1),t_obj(2),t_obj(3))) ).to_equal(anydata.convertCollection(ol_expected) );
end;
procedure not_equal_obj_lists is
begin
ut.expect( anydata.convertCollection(obj_list(t_obj(1),t_obj(3),t_obj(3))) ).to_equal(anydata.convertCollection(ol_expected) );
end;
end test_collections;
/
begin
ut.run('test_collections');
end;
/which gives this output:
compare collection types
equal num_lists [,984 sec]
not equal num_lists [,019 sec] (FAILED - 1)
equal str_lists [,015 sec]
not equal str_lists [,01 sec] (FAILED - 2)
equal obj_lists [,06 sec]
not equal obj_lists [,26 sec] (FAILED - 3)
Failures:
1) not_equal_num_lists
Actual: ursus.num_list [ count = 3 ] was expected to equal: ursus.num_list [ count = 3 ]
Diff:
Rows: [ 1 differences ]
All rows are different as the columns are not matching.
at "URSUS.TEST_COLLECTIONS", line 14 ut.expect( anydata.convertCollection(num_list(1,3,3)) ).to_equal(anydata.convertCollection(nl_expected) );
2) not_equal_str_lists
Actual: ursus.str_list [ count = 3 ] was expected to equal: ursus.str_list [ count = 3 ]
Diff:
Rows: [ 1 differences ]
All rows are different as the columns are not matching.
at "URSUS.TEST_COLLECTIONS", line 24 ut.expect( anydata.convertCollection(str_list('A','C','C')) ).to_equal(anydata.convertCollection(sl_expected) );
3) not_equal_obj_lists
Actual: ursus.obj_list [ count = 3 ] was expected to equal: ursus.obj_list [ count = 3 ]
Diff:
Rows: [ 1 differences ]
Row No. 2 - Actual: <ID>3</ID>
Row No. 2 - Expected: <ID>2</ID>
at "URSUS.TEST_COLLECTIONS", line 34 ut.expect( anydata.convertCollection(obj_list(t_obj(1),t_obj(3),t_obj(3))) ).to_equal(anydata.convertCollection(ol_expected) );
Finished in 1,351811 seconds
6 tests, 3 failed, 0 errored, 0 disabled, 0 warning(s)
Activity
jgebal commentedon Feb 16, 2019
Thanks for reporting this bug.
It's a gap in our self-testing. Let me see why we have that issue.
jgebal commentedon Feb 16, 2019
Just for completeness:
select ut.version() from dual;select * from v$version;blitzkopf commentedon Feb 16, 2019
utPLSQL version v3.1.3.2402
Oracle Version:
jgebal commentedon Feb 16, 2019
I think I've found what is causing the issue, now just need to figure out how to fix it properly.
Thanks for reporting the problem - it allows us to make the product better.
jgebal commentedon Feb 16, 2019
The issue is with how different data-types are represented in XML.
function
ut_compound_data_helper.get_rows_difftries to extract the individual attributes of type.The trouble is, there are no elements for table of scalars.
Need to investigate a bit more to understand how to fix this nicely.
Probably will need to check if element of collection is scalar or object and perform different operations for scalar.
jgebal commentedon Feb 16, 2019
This is the line causing issues:
table( xmlsequence( extract(r.item_data,'/*/*') ) ) slwasylow commentedon Feb 26, 2019
I will look into that when working on pulling anydata under refcursor.
I see that behaviour in my current development so will have to address that.
lwasylow commentedon Mar 1, 2019
Currently still in feature branch but changes will look like:
jgebal commentedon Mar 14, 2019
@lwasylow - I believe this is now getting resolved with your PR, right?
lwasylow commentedon Mar 14, 2019
@jgebal Yes thats correct, results above are generated using my PR.