Skip to content

Cursor comparison not detecting duplicate rows #1293

Description

@DLakomy

Describe the bug
When I compare two cursors using .join_by the duplicate rows are not detected (I'm attaching an example code).

Provide version info
Oracle Database 23ai Free Release 23.0.0.0.0
utPLSQL version: v3.1.14.4197
NLS: Polish
OS: x86_64/Linux 2.4.xx

Information about client software
Client: SQLDeveloper

To Reproduce
Steps to reproduce the behavior:

  1. Prepare two identical cursors with a column you can join on.
  2. Ensure one of the cursors has an additional row, identical to the ones already present.
  3. Run ut.expect to compare them using .join_by(...).
  4. See a message (via dbms_output) indicating a SUCCESS, yet clearly stating different rowcounts.

Expected behavior
The expectation should result in a FAILURE, not a SUCCESS. The rowcounts are clearly different, so the cursors don't yield the same rows, hence are not equal.

Example code

set serveroutput on
declare
  l_actual   sys_refcursor;
  l_expected sys_refcursor;
begin
  open l_expected for 
    select 'FOO'  username, 12 from dual union all
    select 'TEST' username, -600 user_id from dual
    order by 1 desc;
  open l_actual for 
    select 'FOO'  username, 12 from dual union all
    select 'TEST' username, -600 user_id from dual union all
    -- DUPLICATE!!!
    select 'TEST' username, -600 user_id from dual
    order by 1 asc;
  ut.expect( l_actual ).to_equal( l_expected ).join_by('USERNAME');
end;
/
--------
/* The result is:
SUCCESS
  Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 2 ]
*/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions