8000 Merge pull request #871 from utPLSQL/feature/report_on_custom_datatype · utPLSQL/utPLSQL@e6d3257 · GitHub
[go: up one dir, main page]

Skip to content

Commit e6d3257

Browse files
authored
Merge pull request #871 from utPLSQL/feature/report_on_custom_datatype
Feature/report on custom datatype
2 parents c5b9d33 + 3573ae9 commit e6d3257

File tree

8 files changed

+75
-17
lines changed

8 files changed

+75
-17
lines changed

source/create_synonyms_and_grants_for_public.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to public;
107107
grant execute on &&ut3_owner..ut_matcher_options to public;
108108
grant execute on &&ut3_owner..ut_matcher_options_items to public;
109109
grant execute on &&ut3_owner..ut_run_info to public;
110-
grant execute on &&ut3_owner..ut_cursor_column_tab to public;
111-
grant execute on &&ut3_owner..ut_cursor_details to public;
112110

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

@@ -169,5 +167,3 @@ create public synonym dbmspcc_blocks for &&ut3_owner..dbmspcc_blocks;
169167
create public synonym dbmspcc_runs for &&ut3_owner..dbmspcc_runs;
170168
create public synonym dbmspcc_units for &&ut3_owner..dbmspcc_units;
171169
create public synonym ut_run_info for &&ut3_owner..ut_run_info;
172-
create public synonym ut_cursor_column_tab for &&ut3_owner..ut_cursor_column_tab;
173-
create public synonym ut_cursor_details for &&ut3_owner..ut_cursor_details;

source/create_user_grants.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,3 @@ grant select, insert, delete, update on &&ut3_owner..dbmspcc_units to &ut3_user;
126126
grant execute on &&ut3_owner..ut_matcher_options to &ut3_user;
127127
grant execute on &&ut3_owner..ut_matcher_options_items to &ut3_user;
128128
grant execute on &&ut3_owner..ut_run_info to &ut3_user;
129-
grant execute on &&ut3_owner..ut_cursor_column_tab to &ut3_user;
130-
grant execute on &&ut3_owner..ut_cursor_details to &ut3_user;

source/create_user_synonyms.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,3 @@ create or replace synonym &ut3_user..dbmspcc_blocks for &&ut3_owner..dbmspcc_blo
109109
create or replace synonym &ut3_user..dbmspcc_runs for &&ut3_owner..dbmspcc_runs;
110110
create or replace synonym &ut3_user..dbmspcc_units for &&ut3_owner..dbmspcc_units;
111111
create or replace synonym &ut3_user..ut_run_info for &&ut3_owner..ut_run_info;
112-
create or replace synonym &ut3_user..ut_cursor_column_tab for &&ut3_owner..ut_cursor_column_tab;
113-
create or replace synonym &ut3_user..ut_cursor_details for &&ut3_owner..ut_cursor_details;

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,16 @@ create or replace package body ut_compound_data_helper is
7979
execute immediate q'[with
8080
expected_cols as (
8181
select access_path exp_column_name,column_position exp_col_pos,
82-
replace(column_type,'VARCHAR2','CHAR') exp_col_type_compare, column_type exp_col_type
82+
replace(column_type_name,'VARCHAR2','CHAR') exp_col_type_compare, column_type_name exp_col_type
8383
from table(:a_expected)
84+
where parent_name is null and hierarchy_level = 1 and column_name is not null
8485
),
8586
actual_cols as (
8687
select access_path act_column_name,column_position act_col_pos,
87-
replace(column_type,'VARCHAR2','CHAR') act_col_type_compare, column_type act_col_type
88-
from table(:a_actual)),
88+
replace(column_type_name,'VARCHAR2','CHAR') act_col_type_compare, column_type_name act_col_type
89+
from table(:a_actual)
90+
where parent_name is null and hierarchy_level = 1 and column_name is not null
91+
),
8992
joined_cols as (
9093
select e.*,a.*]'
9194
|| case when a_order_enforced then ',

source/expectations/data_values/ut_cursor_column.tpb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ create or replace type body ut_cursor_column as
1212
self.column_position := a_col_position; --Position of the column in cursor/ type
1313
self.column_len := a_col_max_len; --length of column
1414
self.column_name := TRIM( BOTH '''' FROM a_col_name); --name of the column
15-
self.column_type_name := a_col_type_name; --type name e.g. test_dummy_object or varchar2
15+
self.column_type_name := coalesce(a_col_type_name,a_col_type); --type name e.g. test_dummy_object or varchar2
1616
self.access_path := case when a_access_path is null then
1717
self.column_name
1818
else

source/expectations/data_values/ut_cursor_details.tpb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,10 @@ create or replace type body ut_cursor_details as
195195
member function get_xml_children(a_parent_name varchar2 := null) return xmltype is
196196
l_result xmltype;
197197
begin
198-
select xmlagg(xmlelement(evalname t.column_name,t.column_type,
199-
self.get_xml_children(t.column_name)))
198+
select xmlagg(xmlelement(evalname t.column_name,t.column_type_name))
200199
into l_result
201200
from table(self.cursor_columns_info) t
202-
where (a_parent_name is not null and parent_name = a_parent_name and hierarchy_level > 1 and column_name is not null)
203-
or (a_parent_name is null and parent_name is null and hierarchy_level = 1 and column_name is not null)
201+
where (a_parent_name is null and parent_name is null and hierarchy_level = 1 and column_name is not null)
204202
having count(*) > 0;
205203

206204
return l_result;

test/core/expectations/test_expectations_cursor.pkb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,5 +2465,65 @@ Diff:%
24652465
ut.expect(l_actual_message).to_be_like(l_expected_message);
24662466
end;
24672467

2468+
procedure udt_messg_format_eq is
2469+
l_actual sys_refcursor;
2470+
l_expected sys_refcursor;
2471+
l_expected_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs();
2472+
l_expected_message varchar2(32767);
2473+
l_actual_message varchar2(32767);
2474+
begin
2475+
select ut3.ut_key_value_pair(rownum,'Something '||rownum)
2476+
bulk collect into l_expected_tab
2477+
from dual connect by level <=2;
2478+
2479+
--Arrange
2480+
open l_actual for select object_name, owner from all_objects where rownum < 3;
2481+
open l_expected for select value(x) as udt from table(l_expected_tab) x;
2482+
2483+
--Act
2484+
ut3.ut.expect(l_actual).to_contain(l_expected);
2485+
--Assert
2486+
l_expected_message := q'[%Actual: refcursor [ count = 2 ] was expected to contain: refcursor [ count = 2 ]
2487+
%Diff:
2488+
%Columns:
2489+
%Column <UDT> [data-type: UT_KEY_VALUE_PAIR] is missing. Expected column position: 1.
2490+
%Column <OBJECT_NAME> [position: 1, data-type: VARCHAR2] is not expected in results.
2491+
%Column <OWNER> [position: 2, data-type: VARCHAR2] is not expected in results.
2492+
%Rows: [ 2 differences ]
2493+
%Missing: <UDT><KEY>1</KEY><VALUE>Something 1</VALUE></UDT>
2494+
%Missing: <UDT><KEY>2</KEY><VALUE>Something 2</VALUE></UDT>%]';
2495+
l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
2496+
--Assert
2497+
ut.expect(l_actual_message).to_be_like(l_expected_message);
2498+
end;
2499+
2500+
procedure udt_messg_format_empt is
2501+
l_actual sys_refcursor;
2502+
l_actual_tab ut3.ut_key_value_pairs := ut3.ut_key_value_pairs();
2503+
l_actual_message varchar2(32767);
2504+
l_expected_message varchar2(32767);
2505+
begin
2506+
select ut3.ut_key_value_pair(rownum,'Something '||rownum)
2507+
bulk collect into l_actual_tab
2508+
from dual connect by level <=2;
2509+
2510+
--Arrange
2511+
open l_actual for select value(x) as udt from table(l_actual_tab) x;
2512+
2513+
--Act
2514+
ut3.ut.expect(l_actual).to_be_empty();
2515+
--Assert
2516+
l_expected_message := q'[%Actual: (refcursor [ count = 2 ])
2517+
%Data-types:
2518+
%<UDT>UT_KEY_VALUE_PAIR</UDT>
2519+
%Data:
2520+
%<ROW><UDT><KEY>1</KEY><VALUE>Something 1</VALUE></UDT></ROW><ROW><UDT><KEY>2</KEY><VALUE>Something 2</VALUE></UDT></ROW>
2521+
%was expected to be empty%]';
2522+
2523+
l_actual_message := ut3.ut_expectation_processor.get_failed_expectations()(1).message;
2524+
--Assert
2525+
ut.expect(l_actual_message).to_be_like(l_expected_message);
2526+
end;
2527+
24682528
end;
24692529
/

test/core/expectations/test_expectations_cursor.pks

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ create or replace package test_expectations_cursor is
390390

391391
--%test(Cursor to contain duplicates fail)
392392
procedure to_contain_duplicates_fail;
393-
393+
394+
--%test(Display a message with a uer defined type with only type name not structure on equal)
395+
procedure udt_messg_format_eq;
396+
397+
--%test(Display a message with a uer defined type with only type name not structure on empty)
398+
procedure udt_messg_format_empt;
394399
end;
395400
/

0 commit comments

Comments
 (0)
0