Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a33c25

Browse files
committed
Update documentation
Update if statement to simplify Remove synonyms for temp tables
1 parent a5e6aae commit 8a33c25

4 files changed

Lines changed: 26 additions & 7 deletions

File tree

docs/userguide/advanced_data_comparison.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Advanced data-comparison options are available for the [`equal`](expectations.md
2323
- `exclude(a_items varchar2)` - item or comma separated list of items to exclude
2424
- `include(a_items ut_varchar2_list)` - table of items to include
2525
- `exclude(a_items ut_varchar2_list)` - table of items to exclude
26+
- `unordered` - perform compare on unordered set of data, return only missing or actual
27+
- `join_by(a_columns varchar2)` - columns or comma seperated list of columns to join two cursors by
28+
- `join_by(a_columns ut_varchar2_list)` - table of columns to join two cursors by
2629

2730
Each item in the comma separated list can be:
2831
- a column name of cursor to be compared
@@ -92,6 +95,27 @@ Only the columns 'RN', "A_Column" will be compared. Column 'SOME_COL' is exclude
9295

9396
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.
9497

98+
## Join By option
99+
You can now join two cursors by defining a primary key or composite key that will be used to uniqely identify and compare rows. This option allows us to exactly show which rows are missing, extra and which are diffrent without ordering clause.
100+
101+
```sql
102+
procedure join_by_username is
103+
l_actual sys_refcursor;
104+
l_expected sys_refcursor;
105+
begin
106+
open l_expected for select username, user_id from all_users
107+
union all
108+
select 'TEST' username, -600 user_id from dual
109+
order by 1 desc;
110+
open l_actual for select username, user_id from all_users
111+
union all
112+
select 'TEST' username, -610 user_id from dual
113+
order by 1 asc;
114+
ut.expect( l_actual ).to_equal( l_expected ).join_by('USERNAME');
115+
end;
116+
```
117+
This will show you diffrence in row 'TEST' regardless of order.
118+
95119
## Defining item as XPath
96120
When using XPath expression, keep in mind the following:
97121

source/create_synonyms_and_grants_for_public.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ create public synonym ut_file_mapping for &&ut3_owner..ut_file_mapping;
142142
create public synonym ut_file_mapper for &&ut3_owner..ut_file_mapper;
143143
create public synonym ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs;
144144
create public synonym ut_key_value_pair for &&ut3_owner..ut_key_value_pair;
145-
create public synonym ut_compound_data_tmp for &&ut3_owner..ut_compound_data_tmp;
146-
create public synonym ut_compound_data_diff_tmp for &&ut3_owner..ut_compound_data_diff_tmp;
147145
create public synonym ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter;
148146
begin
149147
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then

source/create_synonyms_and_grants_for_user.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ create or replace synonym &ut3_user..ut_file_mapper for &&ut3_owner..ut_file_map
164164
create or replace synonym &ut3_user..ut_key_value_pairs for &&ut3_owner..ut_key_value_pairs;
165165
create or replace synonym &ut3_user..ut_key_value_pair for &&ut3_owner..ut_key_value_pair;
166166
create or replace synonym &ut3_user..ut_compound_data_tmp for &&ut3_owner..ut_cursor_data;
167-
create or replace synonym &ut3_user..ut_compound_data_diff_tmp for &&ut3_owner..ut_compound_data_diff_tmp;
168167
create or replace synonym &ut3_user..ut_sonar_test_reporter for &&ut3_owner..ut_sonar_test_reporter;
169168
begin
170169
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then

source/expectations/data_values/ut_compound_data_value.tpb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ create or replace type body ut_compound_data_value as
7373

7474
overriding member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2, a_unordered boolean := false ) return varchar2 is
7575
l_result clob;
76-
l_result_string varchar2(32767);
76+
l_result_string varchar2(32767);
7777
begin
78-
if a_join_by_xpath is not null then
79-
l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath);
80-
elsif a_unordered then
78+
if a_unordered then
8179
l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_unordered);
8280
else
8381
l_result := get_data_diff(a_other, a_exclude_xpath, a_include_xpath, a_join_by_xpath);

0 commit comments

Comments
 (0)