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

Skip to content

Commit 8898aa4

Browse files
authored
Merge pull request #872 from utPLSQL/fix/missing_priv_on_get_hash
Moving a compare SQL into helper function to avoid privs issue
2 parents 812d56a + 844f0bf commit 8898aa4

7 files changed

Lines changed: 54 additions & 3 deletions

File tree

source/expectations/data_values/ut_compound_data_helper.pkb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,18 @@ create or replace package body ut_compound_data_helper is
586586
end;
587587
end;
588588

589+
function get_compare_cursor(a_diff_cursor_text in clob,a_self_id raw, a_other_id raw) return sys_refcursor is
590+
l_diff_cursor sys_refcursor;
591+
begin
592+
open l_diff_cursor for a_diff_cursor_text using a_self_id, a_other_id;
593+
return l_diff_cursor;
594+
exception when others then
595+
if l_diff_cursor%isopen then
596+
close l_diff_cursor;
597+
end if;
598+
raise;
599+
end;
600+
589601
begin
590602
g_anytype_name_map(dbms_types.typecode_date) := 'DATE';
591603
g_anytype_name_map(dbms_types.typecode_number) := 'NUMBER';

source/expectations/data_values/ut_compound_data_helper.pks

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ create or replace package ut_compound_data_helper authid definer is
8989
function is_sql_compare_allowed(a_type_name varchar2) return boolean;
9090

9191
function get_column_type_desc(a_type_code in integer, a_dbms_sql_desc in boolean) return varchar2;
92-
92+
93+
function get_compare_cursor(a_diff_cursor_text in clob,a_self_id raw, a_other_id raw) return sys_refcursor;
94+
9395
end;
9496
/

source/expectations/data_values/ut_data_value_refcursor.tpb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ create or replace type body ut_data_value_refcursor as
306306
l_diff_id := ut_compound_data_helper.get_hash(a_self.data_id||a_other.data_id);
307307

308308
begin
309-
open l_cursor for a_diff_cursor_text using a_self.data_id, a_other.data_id;
309+
l_cursor := ut_compound_data_helper.get_compare_cursor(a_diff_cursor_text,
310+
a_self.data_id, a_other.data_id);
310311
--fetch and save rows for display of diff
311312
fetch l_cursor bulk collect into l_diff_tab limit ut_utils.gc_diff_max_rows;
312313

test/core/min_grant_user/test_min_grant_user.pkb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ create or replace package body test_min_grant_user is
5555
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
5656

5757
end;
58+
59+
procedure test_equal_non_diff_sql is
60+
l_results clob;
61+
begin
62+
execute immediate 'begin ut3$user#.test_cursor_grants.run_test_equal_non_diff_sql(); end;';
63+
l_results := core.get_dbms_output_as_clob();
64+
--Assert
65+
ut.expect( l_results ).to_be_like( '%execute test with non diff datatype [% sec]' ||
66+
'%1 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)%' );
67+
68+
end;
5869

5970
end;
6071
/

test/core/min_grant_user/test_min_grant_user.pks

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ create or replace package test_min_grant_user is
1818
--%test(execute empty test)
1919
procedure test_empty_cursor;
2020

21+
--%test(execute test with non diff datatype)
22+
procedure test_equal_non_diff_sql;
23+
2124
end;
2225
/

test/helpers/ut3user#.test_cursor_grants.pkb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ create or replace package body ut3$user#.test_cursor_grants is
2424
begin
2525
ut3.ut.run('test_cursor_grants.test_empty_cursor');
2626
end;
27+
28+
procedure run_test_equal_non_diff_sql is
29+
begin
30+
ut3.ut.run('test_cursor_grants.test_equal_non_diff_sql');
31+
end;
2732

2833
procedure test_join_by_cursor is
2934
l_actual SYS_REFCURSOR;
@@ -92,5 +97,18 @@ create or replace package body ut3$user#.test_cursor_grants is
9297
ut3.ut.expect(l_expected).to_be_empty();
9398
end;
9499

100+
procedure test_equal_non_diff_sql is
101+
l_actual SYS_REFCURSOR;
102+
l_expected SYS_REFCURSOR;
103+
begin
104+
open l_actual for
105+
select to_clob('test1') as item from dual;
106+
107+
open l_expected for
108+
select to_clob('test1') as item from dual;
109+
110+
ut3.ut.expect(l_actual).to_equal(l_expected);
111+
end;
112+
95113
end;
96114
/

test/helpers/ut3user#.test_cursor_grants.pks

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ create or replace package ut3$user#.test_cursor_grants is
66
procedure run_test_not_empty_cursor;
77
procedure run_test_have_count_cursor;
88
procedure run_test_empty_cursor;
9-
9+
procedure run_test_equal_non_diff_sql;
10+
1011
--%test(execute join by test)
1112
procedure test_join_by_cursor;
1213

@@ -22,5 +23,8 @@ create or replace package ut3$user#.test_cursor_grants is
2223
--%test(execute empty test)
2324
procedure test_empty_cursor;
2425

26+
--%test(execute test with non diff datatype)
27+
procedure test_equal_non_diff_sql;
28+
2529
end;
2630
/

0 commit comments

Comments
 (0)