Description
Describe the bug
When comparing nested objects, the report produced is confusing and unreadable.
Provide version info
Information about utPLSQL and Database version,
DB version 18.0.0
utPLSQL v3.1.11.3392-develop
Information about client software
not relevant
To Reproduce
Execute the below script
create or replace type obj as object(
value varchar2(200)
);
create or replace type obj_lst as table of obj;
create or replace type test_obj as object (
id number,
lst obj_lst
);
declare
l_expected test_obj;
l_actual test_obj;
begin
l_expected := test_obj(1, obj_lst(obj('1'),obj('2'),obj('3'),obj('2')));
l_actual := test_obj(1, obj_lst(obj('1'),obj('3'),obj('3'),obj('2')));
ut.expect(anydata.convertObject(l_actual)).to_equal(anydata.convertObject(l_expected));
end;
/
The output is:
FAILURE
Actual: ut3_develop.test_obj was expected to equal: ut3_develop.test_obj
Diff:
Rows: [ 1 differences ]
Row No. 1 - Actual: <LST><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ></LST><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ>
Row No. 1 - Expected: <LST><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ></LST><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>1</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>3</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ><OBJ><VALUE>2</VALUE></OBJ>
at "anonymous block", line 7
From looking at the results, it is clear that data is duplicated in the failure report making it impossible to figure out which data element is wrong.
After a bit of formatting on the data we get:
Actual:
<LST>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>3</VALUE> </OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
</LST>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
Expected:
<LST>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
</LST>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>1</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>3</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
<OBJ><VALUE>2</VALUE></OBJ>
It seems like there is a cartesian join of sorts between actual and expected list elements.
Expected behavior
- Duplicates are not present in the list.
- Instead of listing the whole list and individual items, only list the individual items that are wrong with full path
So given the above example, we could have results as follows:
FAILURE
Actual: ut3_develop.test_obj was expected to equal: ut3_develop.test_obj
Diff:
Extra: <LST><OBJ><VALUE>3</VALUE></OBJ></LST>
Missing: <LST><OBJ><VALUE>2</VALUE></OBJ></LST>
at "anonymous block", line 7
Reporting DIFF on a complex structure is a challenge, as it is really hard to figure out how much context is needed to make the report useful and when there is too much context, that makes the report unreadable.
In the above case however, the report is definitely not correct as there are duplicated values in the outcomes.