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

Skip to content

Commit 48ad81e

Browse files
committed
Small fixes and updates regarding peer review.
Updated documentation
1 parent d8525d6 commit 48ad81e

12 files changed

Lines changed: 88 additions & 71 deletions

docs/images/venn21.gif

3.14 KB
Loading

docs/images/venn22.gif

3.4 KB
Loading

docs/userguide/advanced_data_comparison.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ utPLSQL expectations incorporates advanced data comparison options when comparin
66
- object type
77
- nested table and varray
88

9-
Advanced data-comparison options are available for the [`equal`](expectations.md#equal) and [`include/ contain`](expectations.md#include) matcher.
9+
Advanced data-comparison options are available for the [`equal`](expectations.md#equal) and [`include / contain`](expectations.md#include) matcher.
1010

1111
## Syntax
1212

@@ -27,7 +27,7 @@ Advanced data-comparison options are available for the [`equal`](expectations.md
2727
- `exclude(a_items varchar2)` - item or comma separated list of items to exclude
2828
- `include(a_items ut_varchar2_list)` - table of items to include
2929
- `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`***
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
3131
- `join_by(a_columns varchar2)` - columns or comma separated list of columns to join two cursors by
3232
- `join_by(a_columns ut_varchar2_list)` - table of columns to join two cursors by
3333

docs/userguide/expectations.md

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,17 @@ To change the behavior of `NULL = NULL` comparison pass the `a_nulls_are_equal =
437437

438438
This matcher supports only cursor comparison. It check if the give set contain all values from given subset.
439439

440-
Test using this matcher behaves similar to `equal` in respect that it succeeds only when the compared data-types are exactly the same.
440+
when comparing data using `include / contain` matcher, the data-types of columns for compared cursors must be exactly the same.
441441

442442
The matcher supports all advanced comparison options as `equal` e.g. include , exclude, join_by.
443443

444-
The matcher will be successful only when all of the values in expected results are part of actual set.
444+
The matcher is successful when all of the values from expected results are included in actual data set.
445445

446-
In situation where the duplicate is present in expected set we would also expect matching number of occurrences in actual set for matcher to be success.
446+
The matcher will cause a test to fail if any of expected values are not included in actual data set.
447447

448-
*Example 1*
448+
![](D:\Oracle\Devwork\mygit\utPLSQL_pure_sql_cursor\docs\images\venn21.gif)
449+
450+
*Example 1*.
449451

450452
```sql
451453
PROCEDURE ut_refcursors IS
@@ -474,11 +476,56 @@ Will result in failure message
474476
Missing: <ROW><RN>1</RN></ROW>
475477
```
476478

479+
When duplicate rows are present in expected data set, actual data set must also include the same amount of duplicate.
480+
481+
*Example 2.*
477482

478483

479-
Similar negated `not_to_include`/ `not_to_contain` will be successful only when none of the values from expected set are part of actual e.g.
480484

481-
*Example 2.*
485+
```sql
486+
create or replace package ut_duplicate_test is
487+
488+
--%suite(Sample Test Suite)
489+
490+
--%test(Ref Cursor contain duplicates)
491+
procedure ut_duplicate_include;
492+
493+
end ut_duplicate_test;
494+
/
495+
496+
create or replace package body ut_duplicate_test is
497+
procedure ut_duplicate_include is
498+
l_actual sys_refcursor;
499+
l_expected sys_refcursor;
500+
begin
501+
open l_expected for select mod(level,2) as rn from dual connect by level < 5;
502+
open l_actual for select mod(level,8) as rn from dual connect by level < 9;
503+
ut.expect(l_actual).to_include(l_expected);
504+
end;
505+
506+
end ut_duplicate_test;
507+
```
508+
509+
Will result in failure test message
510+
511+
```sql
512+
1) ut_duplicate_include
513+
Actual: refcursor [ count = 8 ] was expected to include: refcursor [ count = 4 ]
514+
Diff:
515+
Rows: [ 2 differences ]
516+
Missing: <RN>0</RN>
517+
Missing: <RN>1</RN>
518+
```
519+
520+
521+
522+
The negated version of `include / contain` ( `not_to_include`/ `not_to_contain` ) is successful only when all values from expected set are not part of actual (they are disjoint and there is no overlap).
523+
524+
525+
526+
![](D:\Oracle\Devwork\mygit\utPLSQL_pure_sql_cursor\docs\images\venn22.gif)
527+
528+
*Example 3.*
482529

483530
Set 1 is defined as [ A , B , C ]
484531

@@ -488,7 +535,7 @@ Set 1 is defined as [ A , B , C ]
488535

489536

490537

491-
*Example 2.*
538+
*Example 4.*
492539

493540
Set 1 is defined as [ A , B , C , D ]
494541

@@ -498,7 +545,7 @@ Set 1 is defined as [ A , B , C , D ]
498545

499546

500547

501-
*Example 3*
548+
*Example 5.
502549

503550
Set 1 is defined as [ A , B , C ]
504551

@@ -681,9 +728,9 @@ utPLSQL is capable of comparing compound data-types including:
681728
### Notes on comparison of compound data
682729
- 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.
683730

684-
- Nested table and varray types are compared as **ordered lists of elements**. If order of elements differ, expectation will fail.
731+
- 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.
685732

686-
- Cursors are compared as **unordered list of elements** by default. If order of elements is of importance the option has to be passed to enforce column order comparison `ordered_columns` e.g.
733+
- Columns in cursors are compared as **unordered list of elements** by default. If order of columns in cursor is of importance the option has to be passed to enforce column order comparison `ordered_columns` e.g.
687734

688735
```sql
689736
procedure ut_refcursors1 is

source/core/types/ut_cursor_info.tps

Lines changed: 0 additions & 22 deletions
This file was deleted.

source/core/ut_utils.pkb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,5 @@ create or replace package body ut_utils is
692692
return l_result;
693693
end;
694694

695-
function serialize_data (a_data clob) return clob is
696-
begin
697-
return replace(a_data,chr(10));
698-
end;
699-
700695
end ut_utils;
701696
/

source/core/ut_utils.pks

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,5 @@ create or replace package ut_utils authid definer is
354354
*/
355355
function replace_multiline_comments(a_source clob) return clob;
356356

357-
--TODO optimize clob replace to be more efficient as might not work replace on large clobs
358-
function serialize_data (a_data clob) return clob;
359-
360357
end ut_utils;
361358
/

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ create or replace package body ut_compound_data_helper is
2020
g_diff_count integer;
2121
g_filter_tab ut_varchar2_list;
2222

23-
type t_type_name_map is table of varchar2(100) index by binary_integer;
23+
type t_type_name_map is table of varchar2(128) index by binary_integer;
2424
g_type_name_map t_type_name_map;
2525
g_anytype_name_map t_type_name_map;
2626
g_anytype_collection_name t_type_name_map;
@@ -352,7 +352,7 @@ create or replace package body ut_compound_data_helper is
352352

353353
begin
354354
dbms_lob.createtemporary(l_compare_sql, true);
355-
gen_sql_pieces_out_of_cursor(a_other.cursor_details.cursor_info, a_join_by_list,
355+
gen_sql_pieces_out_of_cursor(a_other.cursor_details.cursor_columns_info, a_join_by_list,
356356
l_xmltable_stmt, l_select_stmt, l_partition_stmt, l_equal_stmt,
357357
l_join_on_stmt, l_not_equal_stmt);
358358

source/expectations/data_values/ut_cursor_column.tps

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
create or replace type ut_cursor_column force authid current_user as object
22
(
3-
parent_name varchar2(100),
4-
access_path varchar2(500),
3+
parent_name varchar2(4000),
4+
access_path varchar2(4000),
55
has_nested_col number(1,0),
66
transformed_name varchar2(32),
77
hierarchy_level number,
88
column_position number,
9-
xml_valid_name varchar2(100),
10-
column_name varchar2(100),
11-
column_type varchar2(100),
12-
column_type_name varchar2(100),
13-
column_schema varchar2(100),
9+
xml_valid_name varchar2(128),
10+
column_name varchar2(128),
11+
column_type varchar2(128),
12+
column_type_name varchar2(128),
13+
column_schema varchar2(128),
1414
column_len integer,
1515
is_sql_diffable number(1, 0),
1616
is_collection number(1, 0),

source/expectations/data_values/ut_cursor_details.tpb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ create or replace type body ut_cursor_details as
55
begin
66
if self.is_column_order_enforced = 1 then
77
select count(1) into l_diffs
8-
from table(self.cursor_info) a full outer join table(a_other.cursor_info) e
8+
from table(self.cursor_columns_info) a full outer join table(a_other.cursor_columns_info) e
99
on ( decode(a.parent_name,e.parent_name,1,0)= 1 and a.column_name = e.column_name and
1010
REPLACE(a.column_type,'VARCHAR2','CHAR') = REPLACE(e.column_type,'VARCHAR2','CHAR')
1111
and a.column_position = e.column_position )
1212
where a.column_name is null or e.column_name is null;
1313
else
1414
select count(1) into l_diffs
15-
from table(self.cursor_info) a full outer join table(a_other.cursor_info) e
15+
from table(self.cursor_columns_info) a full outer join table(a_other.cursor_columns_info) e
1616
on ( decode(a.parent_name,e.parent_name,1,0)= 1 and a.column_name = e.column_name and
1717
REPLACE(a.column_type,'VARCHAR2','CHAR') = REPLACE(e.column_type,'VARCHAR2','CHAR'))
1818
where a.column_name is null or e.column_name is null;
@@ -155,8 +155,8 @@ create or replace type body ut_cursor_details as
155155
end if;
156156

157157
l_is_collection := ut_compound_data_helper.is_collection(l_attribute_typecode);
158-
self.cursor_info.extend;
159-
self.cursor_info(cursor_info.last) := ut_cursor_column( l_aname,
158+
self.cursor_columns_info.extend;
159+
self.cursor_columns_info(cursor_columns_info.last) := ut_cursor_column( l_aname,
160160
l_schema_name,
161161
null,
162162
l_len,
@@ -176,7 +176,7 @@ create or replace type body ut_cursor_details as
176176

177177
constructor function ut_cursor_details(self in out nocopy ut_cursor_details) return self as result is
178178
begin
179-
self.cursor_info := ut_cursor_column_tab();
179+
self.cursor_columns_info := ut_cursor_column_tab();
180180
return;
181181
end;
182182

@@ -192,7 +192,7 @@ create or replace type body ut_cursor_details as
192192
l_hierarchy_level integer := 1;
193193
l_anytype anytype;
194194
begin
195-
self.cursor_info := ut_cursor_column_tab();
195+
self.cursor_columns_info := ut_cursor_column_tab();
196196
dbms_sql.describe_columns3(a_cursor_number,
197197
l_columns_count,
198198
l_columns_desc);
@@ -205,8 +205,8 @@ create or replace type body ut_cursor_details as
205205
**/
206206
for cur in 1 .. l_columns_count loop
207207
l_is_collection := ut_compound_data_helper.is_collection(l_columns_desc(cur).col_schema_name,l_columns_desc(cur).col_type_name);
208-
self.cursor_info.extend;
209-
self.cursor_info(cursor_info.last) := ut_cursor_column( l_columns_desc(cur).col_name,
208+
self.cursor_columns_info.extend;
209+
self.cursor_columns_info(cursor_columns_info.last) := ut_cursor_column( l_columns_desc(cur).col_name,
210210
l_columns_desc(cur).col_schema_name,
211211
l_columns_desc(cur).col_type_name,
212212
l_columns_desc(cur).col_max_len,

0 commit comments

Comments
 (0)