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

Skip to content

Commit 2b90c4b

Browse files
committed
remove schema quantifier
Changes to remove xpath from diff rows. Signed-off-by: lwasylow <[email protected]>
1 parent 9dc266e commit 2b90c4b

13 files changed

Lines changed: 377 additions & 459 deletions

source/core/ut_utils.pkb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,5 +692,10 @@ 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+
695700
end ut_utils;
696701
/

source/core/ut_utils.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,8 @@ 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+
357360
end ut_utils;
358361
/

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 294 additions & 284 deletions
Large diffs are not rendered by default.

source/expectations/data_values/ut_compound_data_helper.pks

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ create or replace package ut_compound_data_helper authid definer is
5858

5959
type t_diff_tab is table of t_diff_rec;
6060

61+
6162
function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype;
6263

6364
function get_columns_filter(
@@ -72,10 +73,14 @@ create or replace package ut_compound_data_helper authid definer is
7273

7374
function get_rows_diff(
7475
a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw,
75-
a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2,
76-
a_join_by_xpath varchar2,a_refcursor boolean, a_unordered boolean
76+
a_max_rows integer, a_exclude_xpath varchar2, a_include_xpath varchar2
7777
) return tt_row_diffs;
7878

79+
function get_rows_diff_by_sql(a_act_cursor_info ut_cursor_column_tab,a_exp_cursor_info ut_cursor_column_tab,
80+
a_expected_dataset_guid raw, a_actual_dataset_guid raw, a_diff_id raw,
81+
a_join_by_list ut_varchar2_list, a_unordered boolean
82+
) return tt_row_diffs;
83+
7984
subtype t_hash is raw(128);
8085

8186
function get_hash(a_data raw, a_hash_type binary_integer := dbms_crypto.hash_sh1) return t_hash;
@@ -111,12 +116,16 @@ create or replace package ut_compound_data_helper authid definer is
111116
function get_missing_pk(a_expected ut_cursor_column_tab, a_actual ut_cursor_column_tab, a_current_list ut_varchar2_list)
112117
return tt_missing_pk;
113118

119+
function validate_attributes(a_cursor_info ut_cursor_column_tab, a_filter_list ut_varchar2_list) return ut_varchar2_list;
120+
114121
function inc_exc_columns_from_cursor (a_cursor_info ut_cursor_column_tab, a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list)
115122
return ut_cursor_column_tab;
116123

117124
function contains_collection (a_cursor_info ut_cursor_column_tab) return number;
118125

119126
function remove_incomparable_cols( a_cursor_details ut_cursor_column_tab,a_incomparable_cols ut_varchar2_list) return ut_cursor_column_tab;
120127

128+
function generate_missing_cols_warn_msg(a_missing_columns ut_varchar2_list,a_attribute in varchar2) return varchar2;
129+
121130
end;
122131
/

source/expectations/data_values/ut_compound_data_value.tpb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,13 @@ create or replace type body ut_compound_data_value as
118118
dbms_lob.createtemporary(l_result,true);
119119

120120
l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_actual.data_id);
121-
122121
-- First tell how many rows are different
123122
l_diff_row_count := ut_compound_data_helper.get_rows_diff_count;
124123
--TODO : Change message when the types not matching
125124
if l_diff_row_count > 0 then
126125
l_row_diffs := ut_compound_data_helper.get_rows_diff(
127126
self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath,
128-
a_include_xpath, a_join_by_xpath, a_other is of (ut_data_value_refcursor), a_unordered);
127+
a_include_xpath);
129128
l_message := chr(10)
130129
||'Rows: [ ' || l_diff_row_count ||' differences'
131130
|| case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end

source/expectations/data_values/ut_cursor_column.tpb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ create or replace type body ut_cursor_column as
66
a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1,
77
a_col_position integer, a_col_type varchar2, a_collection integer) is
88
begin
9-
self.parent_name := a_parent_name;
10-
self.hierarchy_level := a_hierarchy_level;
11-
self.column_position := a_col_position;
12-
self.column_prec := a_col_prec;
13-
self.column_len := a_col_max_len;
14-
self.column_scale := a_col_scale;
15-
self.column_name := TRIM( BOTH '''' FROM a_col_name);
9+
self.parent_name := a_parent_name;
10+
self.hierarchy_level := a_hierarchy_level;
11+
self.column_position := a_col_position;
12+
self.column_prec := a_col_prec;
13+
self.column_len := a_col_max_len;
14+
self.column_scale := a_col_scale;
15+
self.column_name := TRIM( BOTH '''' FROM a_col_name);
1616
self.column_type_name := a_col_type_name;
17-
self.access_path := case when self.parent_name is null then self.column_name else self.parent_name||'/'||self.column_name end;
18-
self.nested_name := case when self.parent_name is null then
19-
null
17+
self.access_path := case when self.parent_name is null then self.column_name else self.parent_name||'/'||self.column_name end;
18+
self.xml_valid_name := '"'||self.column_name||'"';
19+
self.transformed_name := case when self.parent_name is null then
20+
self.xml_valid_name
2021
else
2122
'"'||ut_compound_data_helper.get_fixed_size_hash(self.parent_name||self.column_name)||'"'
2223
end;
23-
self.xml_valid_name := '"'||self.column_name||'"';
24-
self.column_type := a_col_type;
25-
self.column_schema := a_col_schema_name;
26-
self.is_sql_diffable := case when lower(self.column_type) = 'user_defined_type' then
24+
self.column_type := a_col_type;
25+
self.column_schema := a_col_schema_name;
26+
self.is_sql_diffable := case when lower(self.column_type) = 'user_defined_type' then
2727
0
2828
else
2929
ut_utils.boolean_to_int(ut_curr_usr_compound_helper.is_sql_compare_allowed(self.column_type))

source/expectations/data_values/ut_cursor_column.tps

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
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),
5-
has_nested_col number(1,0),
6-
nested_name varchar2(32),
7-
hierarchy_level number,
8-
column_position number,
9-
xml_valid_name varchar2(100),
10-
column_name varchar2(100),
11-
column_type varchar2(100),
3+
parent_name varchar2(100),
4+
access_path varchar2(500),
5+
has_nested_col number(1,0),
6+
transformed_name varchar2(32),
7+
hierarchy_level number,
8+
column_position number,
9+
xml_valid_name varchar2(100),
10+
column_name varchar2(100),
11+
column_type varchar2(100),
1212
column_type_name varchar2(100),
13-
column_schema varchar2(100),
14-
column_prec integer,
15-
column_len integer,
16-
column_scale integer,
17-
is_sql_diffable number(1, 0),
18-
is_collection number(1, 0),
13+
column_schema varchar2(100),
14+
column_prec integer,
15+
column_len integer,
16+
column_scale integer,
17+
is_sql_diffable number(1, 0),
18+
is_collection number(1, 0),
1919

2020
member procedure init(self in out nocopy ut_cursor_column,
2121
a_col_name varchar2, a_col_schema_name varchar2,

source/expectations/data_values/ut_data_value_refcursor.tpb

Lines changed: 10 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -116,71 +116,7 @@ create or replace type body ut_data_value_refcursor as
116116
return l_result_string;
117117
end;
118118

119-
member function get_data_diff(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2,
120-
a_join_by_xpath varchar2, a_unordered boolean,a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return clob is
121-
c_max_rows integer := ut_utils.gc_diff_max_rows;
122-
l_result clob;
123-
l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab();
124-
l_message varchar2(32767);
125-
l_ut_owner varchar2(250) := ut_utils.ut_owner;
126-
l_diff_row_count integer;
127-
l_actual ut_compound_data_value;
128-
l_diff_id ut_compound_data_helper.t_hash;
129-
l_row_diffs ut_compound_data_helper.tt_row_diffs;
130-
l_compare_type varchar2(10);
131-
l_self ut_compound_data_value;
132-
133-
function get_diff_message (a_row_diff ut_compound_data_helper.t_row_diffs,a_is_unordered boolean) return varchar2 is
134-
begin
135-
136-
if a_is_unordered then
137-
if a_row_diff.pk_value is not null then
138-
return ' PK '||a_row_diff.pk_value||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row;
139-
else
140-
return rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row;
141-
end if;
142-
else
143-
return ' Row No. '||a_row_diff.rn||' - '||rpad(a_row_diff.diff_type,10)||a_row_diff.diffed_row;
144-
end if;
145-
end;
146-
147-
begin
148-
if not a_other is of (ut_compound_data_value) then
149-
raise value_error;
150-
end if;
151-
152-
l_actual := treat(a_other as ut_compound_data_value);
153-
154-
dbms_lob.createtemporary(l_result,true);
155-
156-
l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_actual.data_id);
157-
158-
-- First tell how many rows are different
159-
l_diff_row_count := ut_compound_data_helper.get_rows_diff_count;
160-
--TODO : Change message when the types not matching
161-
if l_diff_row_count > 0 then
162-
l_row_diffs := ut_compound_data_helper.get_rows_diff(
163-
self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath,
164-
a_include_xpath, a_join_by_xpath, a_other is of (ut_data_value_refcursor), a_unordered);
165-
l_message := chr(10)
166-
||'Rows: [ ' || l_diff_row_count ||' differences'
167-
|| case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end
168-
||' ]'||chr(10)|| case when l_row_diffs.count = 0 then ' All rows are different as the columns are not matching.' else null end;
169-
ut_utils.append_to_clob( l_result, l_message );
170-
for i in 1 .. l_row_diffs.count loop
171-
l_results.extend;
172-
l_results(l_results.last) := get_diff_message(l_row_diffs(i),a_unordered);
173-
end loop;
174-
ut_utils.append_to_clob(l_result,l_results);
175-
else
176-
l_message:= chr(10)||'Rows: [ all different ]'||chr(10)||' All rows are different as the columns are not matching.';
177-
ut_utils.append_to_clob( l_result, l_message );
178-
end if;
179-
return l_result;
180-
end;
181-
182-
member function diff( a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2, a_join_by_xpath varchar2,
183-
a_unordered boolean := false, a_join_by_list ut_varchar2_list:=ut_varchar2_list() ) return varchar2 is
119+
member function diff( a_other ut_data_value, a_unordered boolean := false, a_join_by_list ut_varchar2_list:=ut_varchar2_list() ) return varchar2 is
184120
l_result clob;
185121
l_results ut_utils.t_clob_tab := ut_utils.t_clob_tab();
186122
l_result_string varchar2(32767);
@@ -293,9 +229,9 @@ create or replace type body ut_data_value_refcursor as
293229
l_diff_row_count := ut_compound_data_helper.get_rows_diff_count;
294230
l_results := ut_utils.t_clob_tab();
295231
if l_diff_row_count > 0 then
296-
l_row_diffs := ut_compound_data_helper.get_rows_diff(
297-
self.data_id, l_actual.data_id, l_diff_id, c_max_rows, a_exclude_xpath,
298-
a_include_xpath, a_join_by_xpath, a_other is of (ut_data_value_refcursor), a_unordered);
232+
--TODO : since columns can differ we need to pass both list or get common denominator
233+
l_row_diffs := ut_compound_data_helper.get_rows_diff_by_sql(
234+
l_exp_cols,l_act_cols, self.data_id, l_actual.data_id, l_diff_id,a_join_by_list , a_unordered);
299235
l_message := chr(10)
300236
||'Rows: [ ' || l_diff_row_count ||' differences'
301237
|| case when l_diff_row_count > c_max_rows and l_row_diffs.count > 0 then ', showing first '||c_max_rows end
@@ -329,21 +265,19 @@ create or replace type body ut_data_value_refcursor as
329265
return l_result_string;
330266
end;
331267

332-
overriding member function compare_implementation (a_other ut_data_value, a_unordered boolean, a_inclusion_compare boolean := false,
333-
a_is_negated boolean := false, a_join_by_list ut_varchar2_list:=ut_varchar2_list())
334-
return integer is
268+
overriding member function compare_implementation(a_other ut_data_value, a_unordered boolean, a_inclusion_compare boolean := false, a_is_negated boolean := false,
269+
a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return integer is
335270
l_result integer := 0;
336271
l_actual ut_data_value_refcursor;
337-
338272
l_pk_missing_tab ut_compound_data_helper.tt_missing_pk;
339273

340274
begin
341275
if not a_other is of (ut_data_value_refcursor) then
342276
raise value_error;
343277
end if;
344-
278+
345279
l_actual := treat(a_other as ut_data_value_refcursor);
346-
280+
347281
if a_join_by_list.count > 0 then
348282
l_pk_missing_tab := ut_compound_data_helper.get_missing_pk(self.cursor_details.cursor_info,l_actual.cursor_details.cursor_info,a_join_by_list);
349283
l_result := case when (l_pk_missing_tab.count > 0) then 1 else 0 end;
@@ -365,9 +299,9 @@ create or replace type body ut_data_value_refcursor as
365299
return self.elements_count = 0;
366300
end;
367301

368-
member function filter_cursor (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list) return ut_data_value_refcursor is
302+
member function filter_cursor (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list) return ut_data_value_refcursor is
369303
l_result ut_data_value_refcursor := self;
370-
begin
304+
begin
371305
if l_result.cursor_details.cursor_info is not null then
372306
l_result.cursor_details.cursor_info := ut_compound_data_helper.inc_exc_columns_from_cursor(l_result.cursor_details.cursor_info,a_exclude_xpath,a_include_xpath);
373307
end if;

source/expectations/data_values/ut_data_value_refcursor.tps

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,9 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value(
5252
constructor function ut_data_value_refcursor(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor) return self as result,
5353
member procedure init(self in out nocopy ut_data_value_refcursor, a_value sys_refcursor),
5454
overriding member function to_string return varchar2,
55-
member function get_data_diff(a_other ut_data_value, a_exclude_xpath varchar2, a_include_xpath varchar2,
56-
a_join_by_xpath varchar2, a_unordered boolean,a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return clob,
57-
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
58-
,a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return varchar2,
59-
overriding member function compare_implementation(a_other ut_data_value, a_unordered boolean, a_inclusion_compare boolean := false,
60-
a_is_negated boolean := false, a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return integer,
55+
member function diff( a_other ut_data_value, a_unordered boolean := false, a_join_by_list ut_varchar2_list:=ut_varchar2_list() ) return varchar2,
56+
overriding member function compare_implementation(a_other ut_data_value, a_unordered boolean, a_inclusion_compare boolean := false, a_is_negated boolean := false,
57+
a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return integer,
6158
overriding member function is_empty return boolean,
62-
member function filter_cursor (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list) return ut_data_value_refcursor
63-
)
59+
member function filter_cursor (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list) return ut_data_value_refcursor)
6460
/

source/expectations/matchers/ut_equal.tpb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ create or replace type body ut_equal as
255255

256256
member function get_join_by_list return ut_varchar2_list is
257257
begin
258-
--TODO : zamiast zmieniac path zmodyfikuj get functions
259258
return ( coalesce(join_columns, ut_varchar2_list()) );
260259
end;
261260

@@ -268,8 +267,7 @@ create or replace type body ut_equal as
268267
l_result := 0 = treat(self.expected as ut_data_value_anydata).compare_implementation(a_actual, get_exclude_xpath(), get_include_xpath());
269268
elsif self.expected is of (ut_data_value_refcursor) then
270269
l_actual := treat(a_actual as ut_data_value_refcursor).filter_cursor(exclude_list, include_list);
271-
l_result := 0 = treat(self.expected as ut_data_value_refcursor).filter_cursor(exclude_list, include_list).compare_implementation(l_actual,
272-
get_unordered(), false, false, get_join_by_list() );
270+
l_result := 0 = treat(self.expected as ut_data_value_refcursor).filter_cursor(exclude_list, include_list).compare_implementation(l_actual, get_unordered(), false, false, get_join_by_list() );
273271
else
274272
l_result := equal_with_nulls((self.expected = a_actual), a_actual);
275273
end if;
@@ -289,7 +287,7 @@ create or replace type body ut_equal as
289287
l_actual := treat(a_actual as ut_data_value_refcursor).filter_cursor(exclude_list, include_list);
290288
l_result :=
291289
'Actual: '||a_actual.get_object_info()||' '||self.description()||': '||self.expected.get_object_info()
292-
|| chr(10) || 'Diff:' || treat(expected as ut_data_value_refcursor).filter_cursor(exclude_list, include_list).diff(l_actual, get_exclude_xpath(), get_include_xpath(), get_join_by_xpath(), get_unordered(),get_join_by_list());
290+
|| chr(10) || 'Diff:' || treat(expected as ut_data_value_refcursor).filter_cursor(exclude_list, include_list).filter_cursor(exclude_list, include_list).diff(l_actual, get_unordered(),get_join_by_list());
293291
else
294292
l_result :=
295293
'Actual: '||a_actual.get_object_info()||' '||self.description()||': '||self.expected.get_object_info()

0 commit comments

Comments
 (0)