@@ -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;
0 commit comments