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
Copy file name to clipboardExpand all lines: docs/userguide/advanced_data_comparison.md
+53-2Lines changed: 53 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,9 +27,10 @@ Advanced data-comparison options are available for the [`equal`](expectations.md
27
27
-`exclude(a_items varchar2)` - item or comma separated list of items to exclude
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
-
-`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
30
+
-`unordered` - ignore order of data sets when comparing data. Default when comparing data-sets with `to_inclide` / `to_contain`
31
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
+
-`unordered_columns` / `uc` - ignore the ordering of columns / attributes in compared data-sets. Column/attribute names will be used to identify data to be compared and the position will be ignored.
33
34
34
35
Each item in the comma separated list can be:
35
36
- a column name of cursor to be compared
@@ -163,7 +164,7 @@ Above test will result in two differences of one row extra and one row missing.
163
164
164
165
**Note**
165
166
166
-
> `include / contain` matcher is not considering order of compared data-sets by default so using`unordered` makes no difference (it's default)
167
+
> `include / contain` matcher is not considering order of compared data-sets. Using`unordered` makes no difference (it's default)
If you need to perform data comparison of cursors without strictly deending on column order in the returned result-set, use the `unordered_columns` option.
379
+
Shortcut name `uc` is also available for that option.
380
+
381
+
Expectations that compare cursor data with `unordered_Columns` option, will not fail when columns are ordered differently.
382
+
383
+
This option can be useful whn we have no control over the ordering of the column or the column order is not of importance from testing perspective.
384
+
385
+
```sql
386
+
create or replace package test_unordered_columns as
387
+
--%suite
388
+
389
+
--%test
390
+
procedure cursor_include_unordered_cols;
391
+
end;
392
+
/
393
+
394
+
create or replace package body test_unordered_columns as
395
+
396
+
procedure cursor_include_unordered_cols is
397
+
l_actual sys_refcursor;
398
+
l_expected sys_refcursor;
399
+
begin
400
+
--Arrange
401
+
open l_actual for select owner, object_name,object_type from all_objects where owner = user
402
+
order by1,2,3asc;
403
+
open l_expected for select object_type, owner, object_name from all_objects where owner = user
Copy file name to clipboardExpand all lines: docs/userguide/expectations.md
+6-29Lines changed: 6 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -709,38 +709,15 @@ utPLSQL is capable of comparing compound data-types including:
709
709
- nested table/varray types
710
710
711
711
### Notes on comparison of compound data
712
-
- Compound data can contain elements of any data-type. This includes blob, clob, object type, nested table, varray or even a nested-cursor within a cursor.
713
-
714
-
- Attributes in nested table and array types are compared as **ordered lists of elements**. If order of attributes in nested table and array differ, expectation will fail.
715
-
716
-
- Columns in cursors are compared as **ordered list of elements** by default. If order of columns in cursor is not of importance the option has to be passed to enforce column order comparison ` unordered_columns` or a short version `uc` e.g.
717
-
718
-
```sql
719
-
procedure ut_refcursors1 is
720
-
l_actual sys_refcursor;
721
-
l_expected sys_refcursor;
722
-
l_expected_message varchar2(32767);
723
-
l_actual_message varchar2(32767);
724
-
begin
725
-
open l_actual for select1 user_id,'s' a_col,'test' username from dual;
726
-
open l_expected for select'test' username,'s' a_col,1 user_id from dual;
- Compound data can contain elements of any data-type. This includes blob, clob, object type, nested table, varray or even a nested-cursor within a cursor.
714
+
- Attributes in nested table and array types are compared as **ordered lists of elements**. If order of attributes in nested table and array differ, expectation will fail.
715
+
- Columns in cursors are compared as **ordered list of elements** by default. Use `unordered_columns` option when order of columns in cursor is not relevant
733
716
- Comparison of compound data is data-type aware. So a column `ID NUMBER` in a cursor is not the same as `ID VARCHAR2(100)`, even if they both hold the same numeric values.
734
-
735
717
- Comparison of cursor columns containing `DATE` will only compare date part **and ignore time** by default. See [Comparing cursor data containing DATE fields](#comparing-cursor-data-containing-date-fields) to check how to enable date-time comparison in cursors.
736
-
737
-
- Comparison of cursor returning `TIMESTAMP`**columns** against cursor returning `TIMESTAMP`**bind variables** requires variables to be casted to proper precision. This is an Oracle SQL - PLSQL compatibility issue and usage of CAST is the only known workaround for now.
738
-
See [Comparing cursor data containing TIMESTAMP bind variables](#comparing-cursor-data-containing-timestamp-bind-variables) for examples.
739
-
718
+
- Comparison of cursor returning `TIMESTAMP`**columns** against cursor returning `TIMESTAMP`**bind variables** requires variables to be casted to proper precision. This is an Oracle SQL - PLSQL compatibility issue and usage of CAST is the only known workaround for now. See [Comparing cursor data containing TIMESTAMP bind variables](#comparing-cursor-data-containing-timestamp-bind-variables) for examples.
740
719
- To compare nested table/varray type you need to convert it to `anydata` by using `anydata.convertCollection()`
741
-
742
720
- To compare object type you need to convert it to `anydata` by using `anydata.convertObject()`
743
-
744
721
- It is possible to compare PL/SQL records, collections, varrays and associative arrays. To compare this types of data, use cursor comparison feature of utPLSQL and TABLE operator in SQL query
745
722
- On Oracle 11g Release 2 - pipelined table functions are needed (see section [Implicit (Shadow) Types in this artcile](https://oracle-base.com/articles/misc/pipelined-table-functions))
746
723
- On Oracle 12c and above - use [TABLE function on nested tables/varrays/associative arrays of PL/SQL records](https://oracle-base.com/articles/12c/using-the-table-operator-with-locally-defined-types-in-plsql-12cr1)
@@ -749,7 +726,7 @@ utPLSQL is capable of comparing compound data-types including:
749
726
utPLSQL offers advanced data-comparison options, for comparing compound data-types. The options allow you to:
750
727
- define columns/attributes to exclude from comparison
751
728
- define columns/attributes to include in comparison
752
-
-and more
729
+
- and more ...
753
730
754
731
For details on available options and how to use them, read the [advanced data comparison](advanced_data_comparison.md) guide.
755
732
@@ -780,7 +757,7 @@ And the actual cursor data:
780
757
| M | LUKE | SKYWALKER | 1000 | 2 |
781
758
782
759
783
-
The two datasets above have the following differences:
760
+
The two data-sets above have the following differences:
784
761
- column ID is misplaced (should be first column but is last)
785
762
- column SALARY has data-type VARCHAR2 but should be NUMBER
786
763
- column GENDER exists in actual but not in the expected (it is an Extra column)
0 commit comments