I need to compare equality of two results of queries. I can't use utAssert.eqquery because results can have duplicate rows. Real example is a table with primary key, which i have to exclude from check, because values for primary key are generated from sequence.
Test package ut_utassert_eqquery.sql
illustrate the problem. Tests not equal sets with duplicate rows in second set
and not equal sets with duplicate rows in first set
should fail, but they pass.
I implemented a method eqqueryEx
which uses a query like below to check equality:
SELECT a,b,c, COUNT(srс1) cnt1, COUNT(src2) cnt2 FROM ( SELECT a, b, c, 1 srс1, to_number(NULL) src2 FROM tab1 UNION ALL SELECT a, b, c, to_number(NULL) srс1, 1 src2 FROM tab2 ) GROUP BY a,b,c HAVING COUNT(srс1) <> COUNT(src2)
Test package ut_utassert_eqqueryEx.sql
has the same tests which pass/fail as expected.
Attachements:
- patch.patch - patch for my changes
- ut_utassert_eqquery.sql - tests for eqquery
- ut_utassert_eqqueryEx.sql - tests for eqqueryEx
PS. I understand, that usually table should have unique constraints besides primary key, but this is not always the case.