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

Skip to content

Commit ee7bdf2

Browse files
committed
Update order
1 parent c633ff5 commit ee7bdf2

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ create or replace package body ut_compound_data_helper is
183183
l_act_col_filter := get_columns_row_filter(a_exclude_xpath,a_include_xpath,'ucd','act_item_data');
184184
l_exp_col_filter := get_columns_row_filter(a_exclude_xpath,a_include_xpath,'ucd','exp_item_data');
185185

186-
--TODO: Generate a dynamic SQL based on input e.g. no need for PK during unordered and consolidate get_rows_diff
186+
--TODO: Generate SQL based on input as unorder join should aggregate
187187

188188
execute immediate q'[with exp as (
189189
select exp_item_data, exp_data_id, item_no rn,rownum col_no,
@@ -209,23 +209,31 @@ create or replace package body ut_compound_data_helper is
209209
)
210210
select rn, diff_type, diffed_row, pk_value pk_value
211211
from (
212+
select rn, diff_type, diffed_row, pk_value
213+
,case when diff_type = 'Actual:' then 1 else 2 end rnk
214+
,1 final_order
215+
from (
212216
select rn, diff_type, xmlserialize(content data_item no indent) diffed_row, pk_value pk_value
213217
from
214-
(select nvl(exp.rn, act.rn) rn, nvl(exp.pk_value, act.pk_value) pk_value, exp.col exp_item, act.col act_item
218+
(select nvl(exp.rn, act.rn) rn, nvl(exp.pk_value, act.pk_value) pk_value, exp.col exp_item, act.col act_item
215219
from exp join act on exp.rn = act.rn and exp.col_name = act.col_name
216220
where dbms_lob.compare(exp.col_val, act.col_val) != 0)
217221
unpivot ( data_item for diff_type in (exp_item as 'Expected:', act_item as 'Actual:')
218-
)
222+
))
219223
union all
220224
select
221225
item_no as rn, case when exp_data_id is null then 'Extra:' else 'Missing:' end as diff_type,
222226
xmlserialize(content (extract((case when exp_data_id is null then act_item_data else exp_item_data end),'/*/*')) no indent) diffed_row,
223227
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
228+
,case when exp_data_id is null then 1 else 2 end rnk
229+
,2 final_order
224230
from ut_compound_data_diff_tmp i
225231
where diff_id = :diff_id
226232
and act_data_id is null or exp_data_id is null
227233
)
228-
order by rn ,diff_type ]'
234+
order by final_order,
235+
case when final_order = 1 then rn else rnk end,
236+
case when final_order = 1 then rnk else rn end ]'
229237
bulk collect into l_results
230238
using a_exclude_xpath, a_include_xpath, a_join_by_xpath,
231239
a_diff_id, a_expected_dataset_guid,

0 commit comments

Comments
 (0)