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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix : No length datatypes mapping. This is to address issue when Orac…
…le dont expect a length value against data type but cursor description return a max_len not being null.
  • Loading branch information
lwasylow committed Apr 9, 2019
commit 10e651f247ec4279a4c64ddb102b74e579f6a0fd
15 changes: 13 additions & 2 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ create or replace package body ut_compound_data_helper is

g_diff_count integer;
type t_type_name_map is table of varchar2(128) index by binary_integer;
type t_types_no_length is table of varchar2(128) index by varchar2(128);
g_type_name_map t_type_name_map;
g_anytype_name_map t_type_name_map;
g_type_no_length_map t_types_no_length;

g_compare_sql_template varchar2(4000) :=
q'[
Expand Down Expand Up @@ -609,7 +611,7 @@ create or replace package body ut_compound_data_helper is
function type_no_length ( a_type_name varchar2) return boolean is
begin
return case
when a_type_name in ('INTERVAL DAY TO SECOND','INTERVAL YEAR TO MONTH', 'BINARY_FLOAT', 'BINARY_DOUBLE','ROWID') then
when g_type_no_length_map.exists(a_type_name) then
true
else
false
Expand Down Expand Up @@ -661,6 +663,15 @@ begin
g_type_name_map( dbms_sql.urowid_type ) := 'UROWID';
g_type_name_map( dbms_sql.user_defined_type ) := 'USER_DEFINED_TYPE';
g_type_name_map( dbms_sql.ref_type ) := 'REF_TYPE';



/**
* List of types that have no length but can produce a max_len from desc_cursor function.
*/
g_type_no_length_map('ROWID') := 'ROWID';
g_type_no_length_map('INTERVAL DAY TO SECOND') := 'INTERVAL DAY TO SECOND';
g_type_no_length_map('INTERVAL YEAR TO MONTH') := 'INTERVAL YEAR TO MONTH';
g_type_no_length_map('BINARY_DOUBLE') := 'BINARY_DOUBLE';
g_type_no_length_map('BINARY_FLOAT') := 'BINARY_FLOAT';
end;
/
25 changes: 20 additions & 5 deletions test/ut3_user/expectations/test_expectations_cursor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -2591,17 +2591,32 @@ Check the query and data for errors.';
ut.expect(sqlerrm).to_be_like(l_exp_message);
end;

procedure rowid_refcursor is
procedure no_length_datatypes is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
ut3.ut.set_nls;
open l_expected for
select rowid as test from dual;
select cast(3.14 as binary_double) as pi_double,
cast(3.14 as binary_float) as pi_float,
rowid as row_rowid,
numtodsinterval(1.12345678912, 'day') row_ds_interval,
numtoyminterval(1.1, 'year') row_ym_interval
from dual;

open l_actual for
select rowid as test from dual;

ut3.ut.expect(l_actual).to_equal(l_expected);
select cast(3.14 as binary_double) as pi_double,
cast(3.14 as binary_float) as pi_float,
rowid as row_rowid,
numtodsinterval(1.12345678912, 'day') row_ds_interval,
numtoyminterval(1.1, 'year') row_ym_interval
from dual;
--Act
ut3.ut.expect( l_actual ).to_equal( l_expected );
--Assert
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
ut3.ut.reset_nls;

end;
end;
/
4 changes: 2 additions & 2 deletions test/ut3_user/expectations/test_expectations_cursor.pks
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ create or replace package test_expectations_cursor is
--%test(Fail to process a cursor for expected)
procedure xml_error_expected;

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

end;
/