From 0ea86dc2f0f4e369553e089546b1d5c626cd3578 Mon Sep 17 00:00:00 2001 From: lwasylow Date: Fri, 29 Mar 2019 20:16:39 +0000 Subject: [PATCH 1/2] Address issue with whitespace in XML. Cursor describe is ignoring whitespace so max len of column with value ' t ' is showing as 1. XMLTABLE when extracting values from tag with whitespaces its ignoring them. It works properly if there is any character there e.g ' t '. --- .../data_values/ut_compound_data_helper.pkb | 2 + .../data_values/ut_data_value_refcursor.tpb | 14 +++- .../expectations/test_expectations_cursor.pkb | 83 +++++++++++++++++++ .../expectations/test_expectations_cursor.pks | 25 ++++++ 4 files changed, 120 insertions(+), 4 deletions(-) diff --git a/source/expectations/data_values/ut_compound_data_helper.pkb b/source/expectations/data_values/ut_compound_data_helper.pkb index 5ac8a4546..6be8c2ad7 100644 --- a/source/expectations/data_values/ut_compound_data_helper.pkb +++ b/source/expectations/data_values/ut_compound_data_helper.pkb @@ -233,6 +233,8 @@ create or replace package body ut_compound_data_helper is l_col_type := 'VARCHAR2(50)'; elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('INTERVAL DAY TO SECOND','INTERVAL YEAR TO MONTH') then l_col_type := a_data_info.column_type; + elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('VARCHAR2','CHAR') then + l_col_type := 'VARCHAR2('||greatest(a_data_info.column_len,4000)||')'; else l_col_type := a_data_info.column_type ||case when a_data_info.column_len is not null diff --git a/source/expectations/data_values/ut_data_value_refcursor.tpb b/source/expectations/data_values/ut_data_value_refcursor.tpb index 83bd1502f..947d907b5 100644 --- a/source/expectations/data_values/ut_data_value_refcursor.tpb +++ b/source/expectations/data_values/ut_data_value_refcursor.tpb @@ -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(),' Date: Wed, 3 Apr 2019 19:36:12 +0100 Subject: [PATCH 2/2] Update tests --- .../expectations/test_expectations_cursor.pkb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/ut3_user/expectations/test_expectations_cursor.pkb b/test/ut3_user/expectations/test_expectations_cursor.pkb index 3f98b2822..394b643fd 100644 --- a/test/ut3_user/expectations/test_expectations_cursor.pkb +++ b/test/ut3_user/expectations/test_expectations_cursor.pkb @@ -2534,7 +2534,7 @@ Diff:% select column_value t1 from table(ut_varchar2_list(' ')); --Assert ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure insginificant_whitespace2 is @@ -2548,7 +2548,7 @@ Diff:% select 't' t1 from dual; --Assert ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure insginificant_whitespace3 is @@ -2562,7 +2562,7 @@ Diff:% select 't' t1 from dual; --Assert ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure insginificant_whitespace4 is @@ -2576,7 +2576,7 @@ Diff:% select 't' t1 from dual; --Assert ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure insginificant_whitespace5 is @@ -2590,7 +2590,7 @@ Diff:% select '' t1 from dual; --Assert ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; procedure nulltowhitespace is @@ -2604,7 +2604,7 @@ Diff:% select ' ' t1 from dual; --Assert ut3.ut.expect( l_actual ).to_equal( l_expected ); - ut.expect(expectations.failed_expectations_data()).not_to_be_empty(); + ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_be_greater_than(0); end; end; /