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

Skip to content

Different rows not reported when comparing collections of non objects #835

Closed
@blitzkopf

Description

@blitzkopf

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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions