You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -28,7 +28,7 @@ Advanced data-comparison options are available for the [`equal`](expectations.md
28
28
-`include(a_items ut_varchar2_list)` - table of items to include
29
29
-`exclude(a_items ut_varchar2_list)` - table of items to exclude
30
30
-`unordered` - perform compare on unordered set of data, return only missing or actual, ***not supported for `include / contain`*** , as alternative `join_by` can be used
31
-
-`join_by(a_columns varchar2)` - columns or comma separated list of columns to join two cursors by
31
+
-`join_by(a_columns varchar2)` - column or comma separated list of columns to join two cursors by
32
32
-`join_by(a_columns ut_varchar2_list)` - table of columns to join two cursors by
33
33
34
34
Each item in the comma separated list can be:
@@ -58,7 +58,7 @@ procedure test_cur_skip_columns_cn is
58
58
l_expected sys_refcursor;
59
59
l_actual sys_refcursor;
60
60
begin
61
-
open l_expected for select'text' ignore_me, d.*from user_tables d;
61
+
open l_expected for select'text' ignore_me, d.*from user_tables dwhere rownum =1;
62
62
open l_actual for selectsysdate"ADate", d.*from user_tables d;
@@ -127,99 +127,106 @@ Only the columns 'RN', "A_Column" will be compared. Column 'SOME_COL' is exclude
127
127
128
128
This option can be useful in scenarios where you need to narrow-down the scope of test so that the test is only focused on very specific data.
129
129
130
-
##Unordered
130
+
##Unordered
131
131
132
132
Unordered option allows for quick comparison of two cursors without need of ordering them in any way.
133
133
134
134
Result of such comparison will be limited to only information about row existing or not existing in given set without actual information about exact differences.
135
135
136
-
**This option is not supported for `include / contain` matcher**
137
-
138
-
139
-
140
136
```sql
141
137
procedure unordered_tst is
142
138
l_actual sys_refcursor;
143
139
l_expected sys_refcursor;
144
140
begin
145
-
open l_expected for select username, user_id from all_users
146
-
union all
147
-
select'TEST' username, -600 user_id from dual
148
-
order by1desc;
149
-
open l_actual for select username, user_id from all_users
> `include / contain` matcher is not considering order of compared data-sets by default so using `unordered` makes no difference (it's default)
172
167
173
168
174
169
## Join By option
175
170
176
-
You can now join two cursors by defining a primary key or composite key that will be used to uniquely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are different without ordering clause. In the situation where the join key is not unique, join will partition set over rows with a same key and join on row number as well as given join key. The extra rows or missing will be presented to user as well as not matching rows.
171
+
The `join_by` syntax enables comparison of unordered cursors by joining cursor data using specified columns.
177
172
178
-
Join by option can be used in conjunction with include or exclude options. However if any of the join keys is part of exclude set, comparison will fail and report to user that sets could not be joined on specific key (excluded).
173
+
You can join two cursors by defining join column(s) that will be used to uniquely identify and compare rows.
174
+
With this option, framework is able to identify which rows are missing, which are extra and which are different without need to have both cursors uniformly ordered.
175
+
When the specified join column(s) are not unique, join will partition set over rows with the same key and join on row number as well as given join key.
176
+
The extra or missing rows will be presented to user as well as all non-matching rows.
177
+
178
+
Join by option can be used in conjunction with include or exclude options.
179
+
However if any of the join keys is part of exclude set, comparison will fail and report to user that sets could not be joined on specific key, as the key was excluded.
179
180
180
181
```sql
181
182
procedure join_by_username is
182
183
l_actual sys_refcursor;
183
184
l_expected sys_refcursor;
184
185
begin
185
-
open l_expected for select username, user_id from all_users
186
-
union all
187
-
select'TEST' username, -600 user_id from dual
188
-
order by1desc;
189
-
open l_actual for select username, user_id from all_users
In case when a there is detected collection inside cursor and we cannot join key. Comparison will present a failed joins and also a message about collection being detected.
304
+
```
305
+
306
+
**Note**
307
+
> `join_by` does not support joining on individual elements of nested table. You can still use data of the nested table as a PK value.
308
+
> When collection is referenced in `join_by`, test will fail with appropriate message, as it cannot perform a join.
272
309
273
310
```sql
311
+
create or replacetypepersonas object(
312
+
name varchar2(100),
313
+
age integer
314
+
)
315
+
/
316
+
create or replacetypepeopleas table of person
317
+
/
318
+
319
+
create or replace package test_join_by is
320
+
--%suite
321
+
322
+
--%test
323
+
procedure test_join_by_collection_elem;
324
+
325
+
end;
326
+
/
327
+
328
+
create or replace package body test_join_by is
329
+
procedure test_join_by_collection_elem is
330
+
l_actual sys_refcursor;
331
+
l_expected sys_refcursor;
332
+
begin
333
+
open l_expected for select people(person('Matt',45)) persons from dual;
334
+
open l_actual for select people(person('Matt',45)) persons from dual;
Actual: refcursor [ count = 1 ] was expected to equal: refcursor [ count = 1 ]
275
344
Diff:
276
-
Unable to join sets:
277
-
Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in expected
278
-
Join key NESTED_TABLE/ANNOTATIONS/TEXT does not exists in actual
279
-
Please make sure that your join clause is not refferring to collection element
345
+
Unable to join sets:
346
+
Join key PERSONS/PERSON/NAME does not exists in expected
347
+
Join key PERSONS/PERSON/NAME does not exists in actual
348
+
Please make sure that your join clause is not refferring to collection element
280
349
```
281
350
282
-
283
-
284
-
***Please note that .join_by option will take longer to process due to need of parsing via primary keys.***
351
+
***Note***
352
+
>`join_by` option is slower to process as it needs to perform a cursor join.
285
353
286
354
## Defining item lists in option
287
355
XPath expressions are deprecated. They are currently still supported but in future versions they can be removed completely. Please use a current standard of defining items filter.
@@ -293,21 +361,13 @@ When using item list expression, keep in mind the following:
293
361
294
362
Example of a valid parameter to include columns: `RN`, `A_Column`, `SOME_COL` in data comparison.
295
363
```sql
296
-
procedure include_col_list_eq is
364
+
procedure include_col_list is
297
365
l_actual sys_refcursor;
298
366
l_expected sys_refcursor;
299
367
begin
300
368
open l_expected for select rownum as rn, 'a'as"A_Column", 'x' SOME_COL from dual a connect by level <4;
301
369
open l_actual for select rownum as rn, 'a'as"A_Column", 'x' SOME_COL, a.*from all_objects a where rownum <4;
0 commit comments