Skip to content

Commit 94e58a0

Browse files
committed
Refactoring - to be continued.
Moved some of responsibilities. Created `ut_matcher_config`
1 parent 97cd079 commit 94e58a0

17 files changed

+365
-227
lines changed

source/create_synonyms_and_grants_for_public.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ grant execute on &&ut3_owner..ut_realtime_reporter to public;
104104
grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to public;
105105
grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to public;
106106
grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to public;
107+
grant execute on &&ut3_owner..ut_matcher_config to public;
108+
grant execute on &&ut3_owner..ut_matcher_config_items to public;
107109

108110
prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC
109111

source/create_user_grants.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,6 @@ grant execute on &&ut3_owner..ut_realtime_reporter to &ut3_user;
123123
grant select, insert, delete, update on &&ut3_owner..dbmspcc_blocks to &ut3_user;
124124
grant select, insert, delete, update on &&ut3_owner..dbmspcc_runs to &ut3_user;
125125
grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user;
126+
grant execute on &&ut3_owner..ut_matcher_config to &ut3_user;
127+
grant execute on &&ut3_owner..ut_matcher_config_items to &ut3_user;
128+

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ create or replace package body ut_compound_data_helper is
1717
*/
1818

1919
g_diff_count integer;
20-
gc_xpath_extract_reg constant varchar2(50) := '^((/ROW/)|^(//)|^(/\*/))?(.*)';
2120
type t_type_name_map is table of varchar2(128) index by binary_integer;
2221
g_type_name_map t_type_name_map;
2322
g_anytype_name_map t_type_name_map;
@@ -630,31 +629,6 @@ create or replace package body ut_compound_data_helper is
630629
return g_diff_count;
631630
end;
632631

633-
--Filter out columns from cursor based on include (exists) or exclude (not exists)
634-
function filter_out_cols(
635-
a_cursor_info ut_cursor_column_tab,
636-
a_current_list ut_varchar2_list,
637-
a_include boolean := true
638-
) return ut_cursor_column_tab is
639-
l_result ut_cursor_column_tab := ut_cursor_column_tab();
640-
l_filter_sql varchar2(32767);
641-
begin
642-
l_filter_sql :=
643-
q'[with
644-
coltab as (
645-
select i.parent_name,i.access_path,i.has_nested_col,i.transformed_name,i.hierarchy_level,i.column_position ,
646-
i.xml_valid_name,i.column_name,i.column_type,i.column_type_name ,i.column_schema,i.column_len,i.is_sql_diffable ,i.is_collection
647-
from table(:cursor_info) i),
648-
filter as (select column_value from table(:current_list))
649-
select ut_cursor_column(i.parent_name,i.access_path,i.has_nested_col,i.transformed_name,i.hierarchy_level,i.column_position ,
650-
i.xml_valid_name,i.column_name,i.column_type,i.column_type_name ,i.column_schema,i.column_len,i.is_sql_diffable ,i.is_collection)
651-
from coltab i where ]'||case when a_include then null else ' not ' end
652-
||q'[exists (select 1 from filter f where regexp_like(i.access_path, '^'||f.column_value||'($|/.*)'))]';
653-
654-
execute immediate l_filter_sql bulk collect into l_result using a_cursor_info,a_current_list;
655-
return l_result;
656-
end;
657-
658632
function get_missing_filter_columns(a_cursor_info ut_cursor_column_tab, a_column_filter_list ut_varchar2_list)
659633
return ut_varchar2_list is
660634
l_result ut_varchar2_list := ut_varchar2_list();
@@ -681,49 +655,7 @@ create or replace package body ut_compound_data_helper is
681655
order by type desc,name;
682656
return l_missing_pk;
683657
end;
684-
685-
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)
686-
return ut_cursor_column_tab is
687-
l_filtered_set ut_varchar2_list := ut_varchar2_list();
688-
l_result ut_cursor_column_tab := ut_cursor_column_tab();
689-
l_include boolean;
690-
begin
691-
-- if include and exclude is not null its columns from include minus exclude
692-
-- If include is not null and exclude is null cursor will have only include
693-
-- If exclude is not null and include is null cursor will have all except exclude
694-
if a_include_xpath.count > 0 and a_exclude_xpath.count > 0 then
695-
select col_names bulk collect into l_filtered_set
696-
from(
697-
select regexp_replace(column_value,gc_xpath_extract_reg,'\5') col_names
698-
from table(a_include_xpath)
699-
minus
700-
select regexp_replace(column_value,gc_xpath_extract_reg,'\5') col_names
701-
from table(a_exclude_xpath)
702-
);
703-
l_include := true;
704-
elsif a_include_xpath.count > 0 and a_exclude_xpath.count = 0 then
705-
select regexp_replace(column_value,gc_xpath_extract_reg,'\5') col_names
706-
bulk collect into l_filtered_set
707-
from table(a_include_xpath);
708-
l_include := true;
709-
elsif a_include_xpath.count = 0 and a_exclude_xpath.count > 0 then
710-
select regexp_replace(column_value,gc_xpath_extract_reg,'\5') col_names
711-
bulk collect into l_filtered_set
712-
from table(a_exclude_xpath);
713-
l_include := false;
714-
elsif a_cursor_info is not null then
715-
l_result:= a_cursor_info;
716-
else
717-
l_result := ut_cursor_column_tab();
718-
end if;
719658

720-
if l_filtered_set.count > 0 then
721-
l_result := filter_out_cols(a_cursor_info,l_filtered_set,l_include);
722-
end if;
723-
724-
return l_result;
725-
end;
726-
727659
function contains_collection (a_cursor_info ut_cursor_column_tab)
728660
return number is
729661
l_collection_elements number;

source/expectations/data_values/ut_compound_data_helper.pks

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,10 @@ create or replace package ut_compound_data_helper authid definer is
125125

126126
function get_rows_diff_count return integer;
127127

128-
function filter_out_cols(
129-
a_cursor_info ut_cursor_column_tab, a_current_list ut_varchar2_list,a_include boolean := true
130-
) return ut_cursor_column_tab;
131-
132128
function get_missing_pk(
133129
a_expected ut_cursor_column_tab, a_actual ut_cursor_column_tab, a_current_list ut_varchar2_list
134130
) return tt_missing_pk;
135-
136-
function inc_exc_columns_from_cursor (
137-
a_cursor_info ut_cursor_column_tab, a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list
138-
) return ut_cursor_column_tab;
139-
131+
140132
function contains_collection (a_cursor_info ut_cursor_column_tab) return number;
141133

142134
function remove_incomparable_cols(

source/expectations/data_values/ut_compound_data_value.tpb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,11 @@ create or replace type body ut_compound_data_value as
193193
end;
194194

195195
member function compare_implementation(
196-
a_other ut_data_value, a_unordered boolean, a_inclusion_compare boolean,
197-
a_is_negated boolean, a_join_by_list ut_varchar2_list := ut_varchar2_list()
196+
a_other ut_data_value,
197+
a_unordered boolean,
198+
a_inclusion_compare boolean,
199+
a_is_negated boolean,
200+
a_join_by_list ut_varchar2_list := ut_varchar2_list()
198201
) return integer is
199202

200203
l_diff_id ut_compound_data_helper.t_hash;

source/expectations/data_values/ut_data_value_refcursor.tpb

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,13 @@ create or replace type body ut_data_value_refcursor as
277277
return l_result_string;
278278
end;
279279

280-
overriding member function compare_implementation(a_other ut_data_value, a_unordered boolean, a_inclusion_compare boolean := false, a_is_negated boolean := false,
281-
a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return integer is
280+
overriding member function compare_implementation(
281+
a_other ut_data_value,
282+
a_unordered boolean,
283+
a_inclusion_compare boolean := false,
284+
a_is_negated boolean := false,
285+
a_join_by_list ut_varchar2_list := ut_varchar2_list()
286+
) return integer is
282287
l_result integer := 0;
283288
l_actual ut_data_value_refcursor;
284289
l_pk_missing_tab ut_compound_data_helper.tt_missing_pk;
@@ -299,8 +304,10 @@ create or replace type body ut_data_value_refcursor as
299304
if (self.cursor_details is not null and l_actual.cursor_details is not null) and (self.cursor_details != l_actual.cursor_details) then
300305
l_result := 1;
301306
end if;
302-
l_result := l_result + (self as ut_compound_data_value).compare_implementation(a_other,a_unordered, a_inclusion_compare,
303-
a_is_negated, a_join_by_list);
307+
l_result := l_result
308+
+ (self as ut_compound_data_value).compare_implementation(
309+
a_other,a_unordered, a_inclusion_compare, a_is_negated, a_join_by_list
310+
);
304311
end if;
305312

306313
return l_result;
@@ -311,12 +318,38 @@ create or replace type body ut_data_value_refcursor as
311318
return self.elements_count = 0;
312319
end;
313320

314-
member function update_cursor_details (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list,a_ordered_columns boolean := false) return ut_data_value_refcursor is
315-
l_result ut_data_value_refcursor := self;
316-
begin
321+
member function update_cursor_details (a_match_options ut_matcher_config) return ut_data_value_refcursor is
322+
l_result ut_data_value_refcursor := self;
323+
c_xpath_extract_reg constant varchar2(50) := '^((/ROW/)|^(//)|^(/\*/))?(.*)';
324+
begin
317325
if l_result.cursor_details.cursor_columns_info is not null then
318-
l_result.cursor_details.cursor_columns_info := ut_compound_data_helper.inc_exc_columns_from_cursor(l_result.cursor_details.cursor_columns_info,a_exclude_xpath,a_include_xpath);
319-
l_result.cursor_details.ordered_columns(a_ordered_columns);
326+
if a_match_options.include().count > 0 then
327+
with included_columns as (
328+
select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names
329+
from table(a_match_options.include())
330+
minus
331+
select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names
332+
from table(a_match_options.exclude())
333+
)
334+
select value(x)
335+
bulk collect into l_result.cursor_details.cursor_columns_info
336+
from table(self.cursor_details.cursor_columns_info) x
337+
where exists(
338+
select 1 from included_columns f where regexp_like( x.access_path, '^'||f.col_names||'($|/.*)' )
339+
);
340+
elsif a_match_options.exclude().count > 0 then
341+
with excluded_columns as (
342+
select regexp_replace( column_value, c_xpath_extract_reg, '\5' ) col_names
343+
from table(a_match_options.exclude())
344+
)
345+
select value(x)
346+
bulk collect into l_result.cursor_details.cursor_columns_info
347+
from table(self.cursor_details.cursor_columns_info) x
348+
where not exists(
349+
select 1 from excluded_columns f where regexp_like( x.access_path, '^'||f.col_names||'($|/.*)' )
350+
);
351+
end if;
352+
l_result.cursor_details.ordered_columns(a_match_options.ordered_columns());
320353
end if;
321354
return l_result;
322355
end;

source/expectations/data_values/ut_data_value_refcursor.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ create or replace type ut_data_value_refcursor under ut_compound_data_value(
3838
overriding member function compare_implementation(a_other ut_data_value, a_unordered boolean, a_inclusion_compare boolean := false, a_is_negated boolean := false,
3939
a_join_by_list ut_varchar2_list:=ut_varchar2_list()) return integer,
4040
overriding member function is_empty return boolean,
41-
member function update_cursor_details (a_exclude_xpath ut_varchar2_list, a_include_xpath ut_varchar2_list,a_ordered_columns boolean := false) return ut_data_value_refcursor
41+
member function update_cursor_details ( a_match_options ut_matcher_config ) return ut_data_value_refcursor
4242
)
4343
/

0 commit comments

Comments
 (0)