Skip to content

Unreadable & misleading results when comparing nested objects #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jgebal opened this issue Jun 21, 2020 · 0 comments · Fixed by #1179
Closed

Unreadable & misleading results when comparing nested objects #1083

jgebal opened this issue Jun 21, 2020 · 0 comments · Fixed by #1179
Assignees
Labels
Milestone

Comments

@jgebal
Copy link
Member

jgebal commented Jun 21, 2020

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.

@jgebal jgebal added the bug label Jun 21, 2020
@lwasylow lwasylow self-assigned this Jan 26, 2022
@lwasylow lwasylow linked a pull request Jan 26, 2022 that will close this issue
@jgebal jgebal added this to the 3.1.12 milestone Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants