Fix/oracle bug with xmlspaces by lwasylow · Pull Request #895 · utPLSQL/utPLSQL · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions source/expectations/data_values/ut_compound_data_helper.pkb
14 changes: 10 additions & 4 deletions source/expectations/data_values/ut_data_value_refcursor.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,22 @@ create or replace type body ut_data_value_refcursor as
dbms_xmlgen.setNullHandling(l_ctx, dbms_xmlgen.empty_tag);
dbms_xmlgen.setMaxRows(l_ctx, c_bulk_rows);
loop
l_xml := dbms_xmlgen.getxmltype(l_ctx);
l_xml := dbms_xmlgen.getxmltype(l_ctx);
exit when dbms_xmlgen.getNumRowsProcessed(l_ctx) = 0;
--Bug in oracle 12.2+ where XML binary storage trimming insignificant whitespaces.
$if dbms_db_version.version = 12 and dbms_db_version.release >= 2 or dbms_db_version.version > 12 $then
l_xml := xmltype( replace(l_xml.getClobVal(),'<ROWSET','<ROWSET xml:space=''preserve'''));
$else
null;
$end
l_elements_count := l_elements_count + dbms_xmlgen.getNumRowsProcessed(l_ctx);
execute immediate
'insert into ' || l_ut_owner || '.ut_compound_data_tmp(data_id, item_no, item_data) ' ||
'values (:self_guid, :self_row_count, :l_xml)'
using in self.data_id, l_set_id, l_xml;
using in self.data_id, l_set_id, l_xml;
l_set_id := l_set_id + c_bulk_rows;
end loop;

ut_expectation_processor.reset_nls_params();
dbms_xmlgen.closeContext(l_ctx);
self.elements_count := l_elements_count;
Expand Down Expand Up @@ -317,8 +324,7 @@ create or replace type body ut_data_value_refcursor as
l_cursor := ut_compound_data_helper.get_compare_cursor(a_diff_cursor_text,
a_self.data_id, a_other.data_id);
--fetch and save rows for display of diff
fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_diff_max_rows;

fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_diff_max_rows;
exception when others then
if l_cursor%isopen then
close l_cursor;
Expand Down
85 changes: 85 additions & 0 deletions test/ut3_user/expectations/test_expectations_cursor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -2676,6 +2676,91 @@ Check the query and data for errors.';
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);

end;


procedure insginificant_whitespace1 is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
open l_expected for
select column_value t1 from table(ut_varchar2_list(''));

open l_actual for
select column_value t1 from table(ut_varchar2_list(' '));
--Assert
ut3.ut.expect( l_actual ).to_equal( l_expected );
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

procedure insginificant_whitespace2 is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
open l_expected for
select ' t ' t1 from dual;

open l_actual for
select 't' t1 from dual;
--Assert
ut3.ut.expect( l_actual ).to_equal( l_expected );
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

procedure insginificant_whitespace3 is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
open l_expected for
select 't ' t1 from dual;

open l_actual for
select 't' t1 from dual;
--Assert
ut3.ut.expect( l_actual ).to_equal( l_expected );
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

procedure insginificant_whitespace4 is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
open l_expected for
select ' t' t1 from dual;

open l_actual for
select 't' t1 from dual;
--Assert
ut3.ut.expect( l_actual ).to_equal( l_expected );
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

procedure insginificant_whitespace5 is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
open l_expected for
select ' ' t1 from dual;

open l_actual for
select '' t1 from dual;
--Assert
ut3.ut.expect( l_actual ).to_equal( l_expected );
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

procedure nulltowhitespace is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
open l_expected for
select cast(null as varchar2(2)) t1 from dual;

open l_actual for
select ' ' t1 from dual;
--Assert
ut3.ut.expect( l_actual ).to_equal( l_expected );
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0);
end;

end;
/
25 changes: 25 additions & 0 deletions test/ut3_user/expectations/test_expectations_cursor.pks