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
4 changes: 4 additions & 0 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ create or replace package body ut_compound_data_helper is
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)||')';
elsif a_data_info.is_sql_diffable = 1 and a_data_info.column_type in ('NUMBER') then
--We cannot use a precision and scale as dbms_sql.describe_columns3 return precision 0 for dual table
-- there is also no need for that as we not process data but only read and compare as they are stored
l_col_type := a_data_info.column_type;
else
l_col_type := a_data_info.column_type
||case when a_data_info.column_len is not null
Expand Down
11 changes: 8 additions & 3 deletions source/expectations/data_values/ut_cursor_column.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ create or replace type body ut_cursor_column as
self in out nocopy ut_cursor_column,
a_col_name varchar2, a_col_schema_name varchar2,
a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1,
a_col_position integer, a_col_type varchar2, a_collection integer,a_access_path in varchar2
a_col_position integer, a_col_type varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer,
a_col_scale integer
) is
begin
self.parent_name := a_parent_name; --Name of the parent if its nested
self.hierarchy_level := a_hierarchy_level; --Hierarchy level
self.column_position := a_col_position; --Position of the column in cursor/ type
self.column_len := a_col_max_len; --length of column
self.column_precision := a_col_precision;
self.column_scale := a_col_scale;
self.column_name := TRIM( BOTH '''' FROM a_col_name); --name of the column
self.column_type_name := coalesce(a_col_type_name,a_col_type); --type name e.g. test_dummy_object or varchar2
self.xml_valid_name := ut_utils.get_valid_xml_name(self.column_name);
Expand Down Expand Up @@ -49,10 +52,12 @@ create or replace type body ut_cursor_column as
constructor function ut_cursor_column( self in out nocopy ut_cursor_column,
a_col_name varchar2, a_col_schema_name varchar2,
a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1,
a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2
a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer,
a_col_scale integer
) return self as result is
begin
init(a_col_name, a_col_schema_name, a_col_type_name, a_col_max_len, a_parent_name,a_hierarchy_level, a_col_position, a_col_type, a_collection,a_access_path);
init(a_col_name, a_col_schema_name, a_col_type_name, a_col_max_len, a_parent_name,a_hierarchy_level, a_col_position,
a_col_type, a_collection,a_access_path,a_col_precision,a_col_scale);
return;
end;

Expand Down
8 changes: 6 additions & 2 deletions source/expectations/data_values/ut_cursor_column.tps
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ create or replace type ut_cursor_column force authid current_user as object (
column_type_name varchar2(128),
column_schema varchar2(128),
column_len integer,
column_precision integer,
column_scale integer,
is_sql_diffable number(1, 0),
is_collection number(1, 0),

member procedure init(self in out nocopy ut_cursor_column,
a_col_name varchar2, a_col_schema_name varchar2,
a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1,
a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2),
a_col_position integer, a_col_type in varchar2, a_collection integer,a_access_path in varchar2, a_col_precision in integer,
a_col_scale integer),

constructor function ut_cursor_column( self in out nocopy ut_cursor_column,
a_col_name varchar2, a_col_schema_name varchar2,
a_col_type_name varchar2, a_col_max_len integer, a_parent_name varchar2 := null, a_hierarchy_level integer := 1,
a_col_position integer, a_col_type in varchar2, a_collection integer, a_access_path in varchar2)
a_col_position integer, a_col_type in varchar2, a_collection integer, a_access_path in varchar2, a_col_precision in integer,
a_col_scale integer)
return self as result,

constructor function ut_cursor_column( self in out nocopy ut_cursor_column) return self as result
Expand Down
12 changes: 9 additions & 3 deletions source/expectations/data_values/ut_cursor_details.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ create or replace type body ut_cursor_details as
l_idx,
ut_compound_data_helper.get_column_type_desc(l_elements_info.type_code,false),
ut_utils.boolean_to_int(l_is_collection),
a_access_path
a_access_path,
l_elements_info.precision,
l_elements_info.scale
);
if l_element_info.attr_elt_type is not null then
desc_compound_data(
Expand All @@ -63,7 +65,9 @@ create or replace type body ut_cursor_details as
l_idx,
ut_compound_data_helper.get_column_type_desc(l_element_info.type_code,false),
ut_utils.boolean_to_int(l_is_collection),
a_access_path
a_access_path,
l_elements_info.precision,
l_elements_info.scale
);
if l_element_info.attr_elt_type is not null then
desc_compound_data(
Expand Down Expand Up @@ -114,7 +118,9 @@ create or replace type body ut_cursor_details as
pos,
ut_compound_data_helper.get_column_type_desc(l_columns_desc(pos).col_type,true),
ut_utils.boolean_to_int(l_is_collection),
null
null,
l_columns_desc(pos).col_precision,
l_columns_desc(pos).col_scale
);

if l_columns_desc(pos).col_type = dbms_sql.user_defined_type or l_is_collection then
Expand Down
29 changes: 28 additions & 1 deletion test/ut3_user/expectations/test_expectations_cursor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,33 @@ Check the query and data for errors.';
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 number_from_dual is
l_actual sys_refcursor;
l_expected sys_refcursor;
begin
open l_expected for select
12345 as n1,
cast(7456123.89 as number(7,-2)) as n2,
cast(7456123.89 as number(9,1)) as n3,
cast(7456123.89 as number(9,2)) as n4,
cast(7456123.89 as number(9)) as n5,
cast(7456123.89 as number(*,1)) as n6,
7456123.89 as n7
from dual;

open l_actual for select
12345 as n1,
7456100 as n2,
7456123.9 as n3,
7456123.89 as n4,
7456124 as n5,
7456123.9 as n6,
7456123.89 as n7
from dual;
ut3.ut.expect(l_actual).to_equal(l_expected);
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
end;

end;
/
3 changes: 3 additions & 0 deletions test/ut3_user/expectations/test_expectations_cursor.pks
Original file line number Diff line number Diff line change
Expand Up @@ -443,5 +443,8 @@ create or replace package test_expectations_cursor is
--%disabled
procedure nulltowhitespace;

--%test(Check precision of number from dual #907)
procedure number_from_dual;

end;
/