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

Skip to content

Commit 10e651f

Browse files
committed
Fix : No length datatypes mapping. This is to address issue when Oracle dont expect a length value against data type but cursor description return a max_len not being null.
1 parent b051324 commit 10e651f

3 files changed

Lines changed: 35 additions & 9 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ create or replace package body ut_compound_data_helper is
1818

1919
g_diff_count integer;
2020
type t_type_name_map is table of varchar2(128) index by binary_integer;
21+
type t_types_no_length is table of varchar2(128) index by varchar2(128);
2122
g_type_name_map t_type_name_map;
2223
g_anytype_name_map t_type_name_map;
24+
g_type_no_length_map t_types_no_length;
2325

2426
g_compare_sql_template varchar2(4000) :=
2527
q'[
@@ -609,7 +611,7 @@ create or replace package body ut_compound_data_helper is
609611
function type_no_length ( a_type_name varchar2) return boolean is
610612
begin
611613
return case
612-
when a_type_name in ('INTERVAL DAY TO SECOND','INTERVAL YEAR TO MONTH', 'BINARY_FLOAT', 'BINARY_DOUBLE','ROWID') then
614+
when g_type_no_length_map.exists(a_type_name) then
613615
true
614616
else
615617
false
@@ -661,6 +663,15 @@ begin
661663
g_type_name_map( dbms_sql.urowid_type ) := 'UROWID';
662664
g_type_name_map( dbms_sql.user_defined_type ) := 'USER_DEFINED_TYPE';
663665
g_type_name_map( dbms_sql.ref_type ) := 'REF_TYPE';
664-
666+
667+
668+
/**
669+
* List of types that have no length but can produce a max_len from desc_cursor function.
670+
*/
671+
g_type_no_length_map('ROWID') := 'ROWID';
672+
g_type_no_length_map('INTERVAL DAY TO SECOND') := 'INTERVAL DAY TO SECOND';
673+
g_type_no_length_map('INTERVAL YEAR TO MONTH') := 'INTERVAL YEAR TO MONTH';
674+
g_type_no_length_map('BINARY_DOUBLE') := 'BINARY_DOUBLE';
675+
g_type_no_length_map('BINARY_FLOAT') := 'BINARY_FLOAT';
665676
end;
666677
/

test/ut3_user/expectations/test_expectations_cursor.pkb

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,17 +2591,32 @@ Check the query and data for errors.';
25912591
ut.expect(sqlerrm).to_be_like(l_exp_message);
25922592
end;
25932593

2594-
procedure rowid_refcursor is
2594+
procedure no_length_datatypes is
25952595
l_actual sys_refcursor;
25962596
l_expected sys_refcursor;
25972597
begin
2598+
ut3.ut.set_nls;
25982599
open l_expected for
2599-
select rowid as test from dual;
2600+
select cast(3.14 as binary_double) as pi_double,
2601+
cast(3.14 as binary_float) as pi_float,
2602+
rowid as row_rowid,
2603+
numtodsinterval(1.12345678912, 'day') row_ds_interval,
2604+
numtoyminterval(1.1, 'year') row_ym_interval
2605+
from dual;
2606+
26002607
open l_actual for
2601-
select rowid as test from dual;
2602-
2603-
ut3.ut.expect(l_actual).to_equal(l_expected);
2608+
select cast(3.14 as binary_double) as pi_double,
2609+
cast(3.14 as binary_float) as pi_float,
2610+
rowid as row_rowid,
2611+
numtodsinterval(1.12345678912, 'day') row_ds_interval,
2612+
numtoyminterval(1.1, 'year') row_ym_interval
2613+
from dual;
2614+
--Act
2615+
ut3.ut.expect( l_actual ).to_equal( l_expected );
2616+
--Assert
26042617
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
2618+
ut3.ut.reset_nls;
2619+
26052620
end;
26062621
end;
26072622
/

test/ut3_user/expectations/test_expectations_cursor.pks

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ create or replace package test_expectations_cursor is
406406
--%test(Fail to process a cursor for expected)
407407
procedure xml_error_expected;
408408

409-
--%test(Check that cursor correctly handles ROWID dataype)
410-
procedure rowid_refcursor;
409+
--%test(Check that cursor correctly handles no length dataypes)
410+
procedure no_length_datatypes;
411411

412412
end;
413413
/

0 commit comments

Comments
 (0)