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

Skip to content

Commit 4d3dadc

Browse files
committed
Update for 11g where error about inline with was raised.
Update test for min grant user as it produces cartesian
1 parent ab593d9 commit 4d3dadc

3 files changed

Lines changed: 40 additions & 33 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +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;
20+
g_diff_count integer;
2121

2222
function get_column_info_xml(a_column_details ut_key_anyval_pair) return xmltype is
2323
l_result varchar2(4000);
@@ -182,46 +182,53 @@ create or replace package body ut_compound_data_helper is
182182
l_act_col_filter := get_columns_row_filter(a_exclude_xpath,a_include_xpath,'ucd','act_item_data');
183183
l_exp_col_filter := get_columns_row_filter(a_exclude_xpath,a_include_xpath,'ucd','exp_item_data');
184184

185-
execute immediate q'[with diff_info as
186-
( select act_data_id, exp_data_id,]'
187-
||l_act_col_filter||','|| l_exp_col_filter||q'[, :join_by join_by, item_no
188-
from ut_compound_data_diff_tmp ucd
189-
where diff_id = :diff_id ),
190-
exp as (
185+
execute immediate q'[with exp as (
191186
select exp_item_data, exp_data_id, item_no rn,rownum col_no,
192187
nvl2(exp_item_data,ut3.ut_compound_data_helper.get_pk_value(i.join_by,exp_item_data),null) pk_value,
193188
s.column_value col, s.column_value.getRootElement() col_name, s.column_value.getclobval() col_val
194-
from diff_info i,
189+
from (
190+
select exp_data_id, ]'||l_exp_col_filter||q'[, :join_by join_by, item_no
191+
from ut_compound_data_diff_tmp ucd
192+
where diff_id = :diff_id
193+
and ucd.exp_data_id = :self_guid) i,
195194
table( xmlsequence( extract(i.exp_item_data,'/*/*') ) ) s
196-
where i.exp_data_id = :self_guid),
195+
),
197196
act as (
198197
select act_item_data, act_data_id, item_no rn, rownum col_no,
199198
nvl2(act_item_data,ut3.ut_compound_data_helper.get_pk_value(i.join_by,act_item_data),null) pk_value,
200199
s.column_value col, s.column_value.getRootElement() col_name, s.column_value.getclobval() col_val
201-
from diff_info i,
200+
from (
201+
select act_data_id, ]'||l_act_col_filter||q'[, :join_by join_by, item_no
202+
from ut_compound_data_diff_tmp ucd
203+
where diff_id = :diff_id
204+
and ucd.exp_data_id = :other_guid ) i,
202205
table( xmlsequence( extract(i.act_item_data,'/*/*') ) ) s
203-
where i.act_data_id = :other_guid)
206+
)
204207
select rn, diff_type, diffed_row, pk_value pk_value
205208
from (
206-
select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, pk_value pk_value
207-
from (
208-
select nvl(exp.rn, act.rn) rn, nvl(exp.pk_value, act.pk_value) pk_value, exp.col exp_item, act.col act_item
209-
from exp join act
210-
on exp.rn = act.rn and exp.col_name = act.col_name
211-
where dbms_lob.compare(exp.col_val, act.col_val) != 0)
212-
unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:') )
209+
select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, pk_value pk_value
210+
from
211+
(select nvl(exp.rn, act.rn) rn, nvl(exp.pk_value, act.pk_value) pk_value, exp.col exp_item, act.col act_item
212+
from exp join act on exp.rn = act.rn and exp.col_name = act.col_name
213+
where dbms_lob.compare(exp.col_val, act.col_val) != 0)
214+
unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:')
215+
)
213216
union all
214-
select item_no as rn, case when exp_data_id is null then 'Extra:' else 'Missing:' end as diff_type,
217+
select
218+
item_no as rn, case when exp_data_id is null then 'Extra:' else 'Missing:' end as diff_type,
215219
xmlserialize(content (case when exp_data_id is null then act_item_data else exp_item_data end) no indent) diffed_row,
216-
nvl2(i.join_by,ut3.ut_compound_data_helper.get_pk_value(i.join_by,case when exp_data_id is null then act_item_data else exp_item_data end),null) pk_value
217-
from diff_info i
218-
where act_data_id is null or exp_data_id is null
220+
nvl2(:join_by,ut3.ut_compound_data_helper.get_pk_value(:join_by,case when exp_data_id is null then act_item_data else exp_item_data end),null) pk_value
221+
from ut_compound_data_diff_tmp i
222+
where diff_id = :diff_id
223+
and act_data_id is null or exp_data_id is null
219224
)
220225
order by 2, 1]'
221226
bulk collect into l_results
222-
using a_exclude_xpath,a_include_xpath,
223-
a_exclude_xpath,a_include_xpath,
224-
a_join_by_xpath, a_diff_id, a_expected_dataset_guid,a_actual_dataset_guid;
227+
using a_exclude_xpath, a_include_xpath, a_join_by_xpath,
228+
a_diff_id, a_expected_dataset_guid,
229+
a_exclude_xpath,a_include_xpath, a_join_by_xpath,
230+
a_diff_id, a_actual_dataset_guid,
231+
a_join_by_xpath,a_join_by_xpath, a_diff_id;
225232

226233
return l_results;
227234
end;
@@ -700,17 +707,17 @@ create or replace package body ut_compound_data_helper is
700707

701708
procedure set_rows_diff(a_rows_diff integer) is
702709
begin
703-
gc_diff_count := a_rows_diff;
710+
g_diff_count := a_rows_diff;
704711
end;
705712

706713
procedure cleanup_diff is
707714
begin
708-
gc_diff_count := 0;
715+
g_diff_count := 0;
709716
end;
710717

711718
function get_rows_diff return integer is
712719
begin
713-
return gc_diff_count;
720+
return g_diff_count;
714721
end;
715722

716723
end;

source/expectations/data_values/ut_curr_usr_compound_helper.pkb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ create or replace package body ut_curr_usr_compound_helper is
5656
l_data := ut_data_value_varchar2(g_type_name_map(a_desc_rec.col_type));
5757
return ut_key_anyval_pair(a_desc_rec.col_name,l_data);
5858
end if;
59+
5960
/*If its a collection regardless is we want to describe user defined types we will return just a name
60-
and capture that name */
61-
61+
and capture that name */
6262
if a_desc_rec.col_type = g_user_defined_type and is_collection(a_desc_rec.col_schema_name,a_desc_rec.col_type_name) then
6363
l_data := ut_data_value_varchar2(a_desc_rec.col_schema_name||'.'||a_desc_rec.col_type_name);
6464
set_collection_state(true);

test/min_grant_user/min_grant_user_exp.pkb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ create or replace package body min_grant_user_exp is
55
l_expected SYS_REFCURSOR;
66
begin
77
--Arrange
8-
open l_actual for select owner, object_name,object_type from all_objects where owner = user
8+
open l_actual for select object_id, owner, object_name,object_type from all_objects where owner = user
99
order by 1,2,3 asc;
10-
open l_expected for select owner, object_name,object_type from all_objects where owner = user
10+
open l_expected for select object_id, owner, object_name,object_type from all_objects where owner = user
1111
order by 1,2,3 desc;
1212

1313
--Act
14-
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OWNER');
14+
ut3.ut.expect(l_actual).to_equal(l_expected).join_by('OBJECT_ID');
1515

1616
end;
1717

0 commit comments

Comments
 (0)