8000 Feature/report on custom datatype by lwasylow · Pull Request #871 · utPLSQL/utPLSQL · GitHub
[go: up one dir, main page]

Skip to content

Feature/report on custom datatype #871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2019
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: 0 additions & 4 deletions source/create_synonyms_and_grants_for_public.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to public;
grant execute on &&ut3_owner..ut_matcher_options to public;
grant execute on &&ut3_owner..ut_matcher_options_items to public;
grant execute on &&ut3_owner..ut_run_info to public;
grant execute on &&ut3_owner..ut_cursor_column_tab to public;
grant execute on &&ut3_owner..ut_cursor_details to public;

prompt Creating synonyms for UTPLSQL objects in &&ut3_owner schema to PUBLIC

Expand Down Expand Up @@ -169,5 +167,3 @@ create public synonym dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks;
create public synonym dbmspcc_runs for &&ut3_owner..dbmspcc_runs;
create public synonym dbmspcc_units for &&ut3_owner..dbmspcc_units;
create public synonym ut_run_info for &&ut3_owner..ut_run_info;
create public synonym ut_cursor_column_tab for &&ut3_owner..ut_cursor_column_tab;
create public synonym ut_cursor_details for &&ut3_owner..ut_cursor_details;
2 changes: 0 additions & 2 deletions source/create_user_grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,3 @@ grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user;
grant execute on &&ut3_owner..ut_matcher_options to &ut3_user;
grant execute on &&ut3_owner..ut_matcher_options_items to &ut3_user;
grant execute on &&ut3_owner..ut_run_info to &ut3_user;
grant execute on &&ut3_owner..ut_cursor_column_tab to &ut3_user;
grant execute on &&ut3_owner..ut_cursor_details to &ut3_user;
2 changes: 0 additions & 2 deletions source/create_user_synonyms.sql
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,3 @@ create or replace synonym &ut3_user..dbmspcc_blocks for &&ut3_owner..dbmspcc_blo
create or replace synonym &ut3_user..dbmspcc_runs for &&ut3_owner..dbmspcc_runs;
create or replace synonym &ut3_user..dbmspcc_units for &&ut3_owner..dbmspcc_units;
create or replace synonym &ut3_user..ut_run_info for &&ut3_owner..ut_run_info;
create or replace synonym &ut3_user..ut_cursor_column_tab for &&ut3_owner..ut_cursor_column_tab;
create or replace synonym &ut3_user..ut_cursor_details for &&ut3_owner..ut_cursor_details;
9 changes: 6 additions & 3 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@ create or replace package body ut_compound_data_helper is
execute immediate q'[with
expected_cols as (
select access_path exp_column_name,column_position exp_col_pos,
replace(column_type,'VARCHAR2','CHAR') exp_col_type_compare, column_type exp_col_type
replace(column_type_name,'VARCHAR2','CHAR') exp_col_type_compare, column_type_name exp_col_type
from table(:a_expected)
where parent_name is null and hierarchy_level = 1 and column_name is not null
),
actual_cols as (
select access_path act_column_name,column_position act_col_pos,
replace(column_type,'VARCHAR2','CHAR') act_col_type_compare, column_type act_col_type
from table(:a_actual)),
replace(column_type_name,'VARCHAR2','CHAR') act_col_type_compare, column_type_name act_col_type
from table(:a_actual)
where parent_name is null and hierarchy_level = 1 and column_name is not null
),
joined_cols as (
select e.*,a.*]'
|| case when a_order_enforced then ',
Expand Down
2 changes: 1 addition & 1 deletion source/expectations/data_values/ut_cursor_column.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ create or replace type body ut_cursor_column as
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_name := TRIM( BOTH '''' FROM a_col_name); --name of the column
self.column_type_name := a_col_type_name; --type name e.g. test_dummy_object or varchar2
self.column_type_name := coalesce(a_col_type_name,a_col_type); --type name e.g. test_dummy_object or varchar2
self.access_path := case when a_access_path is null then
self.column_name
else
Expand Down
6 changes: 2 additions & 4 deletions source/expectations/data_values/ut_cursor_details.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,10 @@ create or replace type body ut_cursor_details as
member function get_xml_children(a_parent_name varchar2 := null) return xmltype is
l_result xmltype;
begin
select xmlagg(xmlelement(evalname t.column_name,t.column_type,
self.get_xml_children(t.column_name)))
select xmlagg(xmlelement(evalname t.column_name,t.column_type_name))
into l_result
from table(self.cursor_columns_info) t
where (a_parent_name is not null and parent_name = a_parent_name and hierarchy_level > 1 and column_name is not null)
or (a_parent_name is null and parent_name is null and hierarchy_level = 1 and column_name is not null)
where (a_parent_name is null and parent_name is null and hierarchy_level = 1 and column_name is not null)
having count(*) > 0;

return l_result;
Expand Down
60 changes: 60 additions & 0 deletions 60 test/core/expectations/test_expectations_cursor.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -2465,5 +2465,65 @@ Diff:%
ut.expect(l_actual_message).to_be_like(l_expected_message);
end;

procedure udt_messg_format_eq is
l_actual sys_refcursor;
l_expected sys_refcursor;
l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs();
l_expected_message varchar2(32767);
l_actual_message varchar2(32767);
begin
select ut3.ut_key_value_pair(rownum,'Something '||rownum)
bulk collect into l_expected_tab
from dual connect by level <=2;

--Arrange
open l_actual for select object_name, owner from all_objects where rownum < 3;
open l_expected for select value(x) as udt from table(l_expected_tab) x;

--Act
ut3.ut.expect(l_actual).to_contain(l_expected);
--Assert
l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to contain: refcursor [ count = 2 ]
%Diff:
%Columns:
%Column <UDT> [data-type: UT_KEY_VALUE_PAIR] is missing. Expected column position: 1.
%Column <OBJECT_NAME> [position: 1, data-type: VARCHAR2] is not expected in results.
%Column <OWNER> [position: 2, data-type: VARCHAR2] is not expected in results.
%Rows: [ 2 differences ]
%Missing: <UDT><KEY>1</KEY><VALUE>Something 1</VALUE></UDT>
%Missing: <UDT><KEY>2</KEY><VALUE>Something 2</VALUE></UDT>%]';
l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
--Assert
ut.expect(l_actual_message).to_be_like(l_expected_message);
end;

procedure udt_messg_format_empt is
l_actual sys_refcursor;
l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs();
l_actual_message varchar2(32767);
l_expected_message varchar2(32767);
begin
select ut3.ut_key_value_pair(rownum,'Something '||rownum)
bulk collect into l_actual_tab
from dual connect by level <=2;

--Arrange
open l_actual for select value(x) as udt from table(l_actual_tab) x;

--Act
ut3.ut.expect(l_actual).to_be_empty();
--Assert
l_expected_message := q'[%Actual: (refcursor [ count = 2 ])
%Data-types:
%<UDT>UT_KEY_VALUE_PAIR</UDT>
%Data:
%<ROW><UDT><KEY>1</KEY><VALUE>Something 1</VALUE></UDT></ROW><ROW><UDT><KEY>2</KEY><VALUE>Something 2</VALUE></UDT></ROW>
%was expected to be empty%]';

l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
--Assert
ut.expect(l_actual_message).to_be_like(l_expected_message);
end;

end;
/
7 changes: 6 additions & 1 deletion test/core/expectations/test_expectations_cursor.pks
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ create or replace package test_expectations_cursor is

--%test(Cursor to contain duplicates fail)
procedure to_contain_duplicates_fail;


--%test(Display a message with a uer defined type with only type name not structure on equal)
procedure udt_messg_format_eq;

--%test(Display a message with a uer defined type with only type name not structure on empty)
procedure udt_messg_format_empt;
end;
/
0