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

Skip to content

Commit b4113fd

Browse files
committed
Check in progress of working version.
Still to define include and exclude.
1 parent ae3d34f commit b4113fd

6 files changed

Lines changed: 43 additions & 23 deletions

File tree

source/api/ut_runner.pkb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ create or replace package body ut_runner is
4949
ut_metadata.reset_source_definition_cache;
5050
ut_utils.read_cache_to_dbms_output();
5151
ut_coverage_helper.cleanup_tmp_table();
52+
ut_compound_data_helper.cleanup_diff();
5253
end;
5354

5455

source/expectations/data_values/ut_compound_data_helper.pkb

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

1919
g_user_defined_type pls_integer := dbms_sql.user_defined_type;
20+
gc_diff_count integer;
2021

2122
function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype is
2223
l_result varchar2(4000);
@@ -822,7 +823,7 @@ create or replace package body ut_compound_data_helper is
822823
where not exists (select 1 from pk_names p where lower(p.name) = lower(xt.name))
823824
)
824825
loop
825-
l_sql_stmt := l_sql_stmt || case when l_sql_stmt is null then null else ' or ' end ||' a.'||i.name||q'[ <> ]'||' e.'||i.name;
826+
l_sql_stmt := l_sql_stmt || case when l_sql_stmt is null then null else ' or ' end ||' (decode(a.'||i.name||','||' e.'||i.name||',1,0) = 0)';
826827
end loop;
827828
return l_sql_stmt;
828829
end;
@@ -872,5 +873,20 @@ create or replace package body ut_compound_data_helper is
872873
(a_diff_id, xmlelement( name "ROW", a_diff_tab(idx).act_item_data), a_diff_tab(idx).act_data_id,xmlelement( name "ROW", a_diff_tab(idx).exp_item_data), a_diff_tab(idx).exp_data_id,a_diff_tab(idx).item_no);
873874
end;
874875

876+
procedure set_rows_diff(a_rows_diff integer) is
877+
begin
878+
gc_diff_count := a_rows_diff;
879+
end;
880+
881+
procedure cleanup_diff is
882+
begin
883+
gc_diff_count := 0;
884+
end;
885+
886+
function get_rows_diff return integer is
887+
begin
888+
return gc_diff_count;
889+
end;
890+
875891
end;
876892
/

source/expectations/data_values/ut_compound_data_helper.pks

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,11 @@ create or replace package ut_compound_data_helper authid definer is
108108

109109
procedure insert_diffs_result(a_diff_tab t_diff_tab, a_diff_id raw);
110110

111+
procedure set_rows_diff(a_rows_diff integer);
112+
113+
procedure cleanup_diff;
114+
115+
function get_rows_diff return integer;
116+
111117
end;
112118
/

source/expectations/data_values/ut_compound_data_value.tpb

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,21 @@ create or replace type body ut_compound_data_value as
121121
l_diff_id := ut_compound_data_helper.get_hash(self.data_id||l_actual.data_id);
122122

123123
-- First tell how many rows are different
124-
execute immediate 'select count('
124+
125+
--REDO that is a bit mess ??
126+
if l_is_sql_diff = 1 then
127+
l_diff_row_count := ut_compound_data_helper.get_rows_diff;
128+
else
129+
execute immediate 'select count('
125130
||case when ( a_join_by_xpath is not null and l_is_sql_diff = 0 )
126131
then 'distinct pk_hash'
127132
else '*'
128133
end
129134
||') from '|| l_ut_owner || '.ut_compound_data_diff_tmp '
130135
||'where diff_id = :diff_id'
131136
into l_diff_row_count using l_diff_id;
132-
137+
end if;
138+
133139
if l_diff_row_count > 0 then
134140
l_compare_type := ut_compound_data_helper.compare_type(a_join_by_xpath,a_unordered, l_is_sql_diff);
135141
l_row_diffs := ut_compound_data_helper.get_rows_diff(
@@ -324,21 +330,14 @@ create or replace type body ut_compound_data_value as
324330
end
325331
||'( a.data_id is null or e.data_id is null )';
326332
end if;
327-
328-
l_exec_sql := 'insert into ' || l_ut_owner || '.ut_compound_data_diff_tmp '
329-
||'( diff_id, act_item_data, act_data_id, exp_item_data, exp_data_id, item_no )'
330-
||' select :diff_id, act_item_data, act_data_id,'
331-
||' exp_item_data, exp_data_id , item_no '
332-
||'from ( '|| l_compare_sql ||')';
333333

334334
open l_loop_curs for l_compare_sql using self.data_id,l_actual.data_id;
335335

336336
loop
337337
fetch l_loop_curs bulk collect into l_diff_tab limit l_max_rows;
338338
exit when l_diff_tab.count = 0;
339339
--Pass it to helper as authid as definer
340-
t1 := dbms_utility.get_time;
341-
340+
342341
if (ut_utils.gc_diff_max_rows > l_sql_rowcount ) then
343342
ut_compound_data_helper.insert_diffs_result(l_diff_tab,l_diff_id);
344343
end if;
@@ -349,12 +348,10 @@ create or replace type body ut_compound_data_value as
349348
l_max_rows := ut_utils.gc_bc_fetch_limit;
350349
end if;
351350

352-
dbms_output.put_line((dbms_utility.get_time - t1)/100 || ' seconds - get col info , values'||l_sql_rowcount);
353351
end loop;
352+
353+
ut_compound_data_helper.set_rows_diff(l_sql_rowcount);
354354

355-
--l_actual.set_difference_count(l_sql_rowcount);
356-
357-
--execute immediate l_exec_sql using l_diff_id, self.data_id,l_actual.data_id;
358355
--result is OK only if both are same
359356
if l_sql_rowcount = 0 and self.elements_count = l_other.elements_count then
360357
l_result := 0;

source/expectations/data_values/ut_compound_data_value.tps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ create or replace type ut_compound_data_value force under ut_data_value(
3434
* Holds unique id for retrieving the data from ut_compound_data_tmp temp table
3535
*/
3636
data_id raw(16),
37-
37+
3838
overriding member function get_object_info return varchar2,
3939
overriding member function is_null return boolean,
4040
overriding member function is_diffable return boolean,

test/core/expectations/test_expectations_cursor.pkb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,13 +1087,13 @@ Rows: [ 2 differences ]%
10871087
l_expected SYS_REFCURSOR;
10881088
begin
10891089
--Arrange
1090-
open l_actual for select owner, object_name,object_type from all_objects where owner = user
1090+
open l_actual for select object_id, owner, object_name,object_type from all_objects where owner = user
10911091
order by 1,2,3 asc;
1092-
open l_expected for select owner, object_name,object_type from all_objects where owner = user
1092+
open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user
10931093
order by 1,2,3 desc;
10941094

10951095
--Act
1096-
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER');
1096+
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID');
10971097
--Assert
10981098
ut.expect(expectations.failed_expectations_data()).to_be_empty();
10991099
end;
@@ -1109,7 +1109,7 @@ Rows: [ 2 differences ]%
11091109
order by 1,2,3 desc;
11101110

11111111
--Act
1112-
ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('OWNER,OBJECT_NAME'));
1112+
ut3.ut.expect(l_actual).to_equal(l_expected).join_by(ut3.ut_varchar2_list('OBJECT_NAME,OBJECT_TYPE'));
11131113
--Assert
11141114
ut.expect(expectations.failed_expectations_data()).to_be_empty();
11151115
end;
@@ -1257,10 +1257,10 @@ Diff:%
12571257
l_expected SYS_REFCURSOR;
12581258
begin
12591259
--Arrange
1260-
open l_actual for select object_name from all_objects where rownum <=1100;
1261-
open l_expected for select object_name from all_objects where rownum <=1100;
1260+
open l_actual for select level object_id, level || '_TEST' object_name from dual connect by level <=1100;
1261+
open l_expected for select level object_id, level || '_TEST' object_name from dual connect by level <=1100;
12621262
--Act
1263-
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_NAME');
1263+
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID');
12641264
--Assert
12651265
ut.expect(expectations.failed_expectations_data()).to_be_empty();
12661266
end;

0 commit comments

Comments
 (0)