8000 Support native JSON data type of Oracle Database 21c by lwasylow · Pull Request #1181 · utPLSQL/utPLSQL · GitHub
[go: up one dir, main page]

Skip to content

Support native JSON data type of Oracle Database 21c #1181

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 12 commits into from
Feb 6, 2022
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
Making tests below 21 compilation conditional so it wont fail.
  • Loading branch information
lwasylow committed Feb 1, 2022
commit 9002fbce682677e8983e3a3e1f338f58aecc0817
11 changes: 11 additions & 0 deletions source/expectations/data_values/ut_compound_data_helper.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,17 @@ create or replace package body ut_compound_data_helper is
return l_diffs;
end;

function get_json_object(a_json_t json) return json_element_t is
l_json JSON;
l_obj json_element_t;
begin
$if dbms_db_version.version >= 21 $then
l_obj := case when a_json_t is null then cast (null as json_element_t ) else json_element_t.parse(json_query(a_value, '$' returning clob)) end;
$else
l_obj := null;
$end
end;

begin
g_anytype_name_map(dbms_types.typecode_date) := 'DATE';
g_anytype_name_map(dbms_types.typecode_number) := 'NUMBER';
Expand Down
2 changes: 2 additions & 0 deletions source/expectations/data_values/ut_compound_data_helper.pks
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,7 @@ create or replace package ut_compound_data_helper authid definer is

function get_json_diffs_type(a_diff_id raw) return tt_json_diff_type_tab;

function get_json_object(a_json_t json) return json_element_t;

end;
/
2 changes: 1 addition & 1 deletion source/expectations/data_values/ut_data_value_json.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ create or replace type body ut_data_value_json as
end;

constructor function ut_data_value_json(self in out nocopy ut_data_value_json, a_value json) return self as result is
l_value json_element_t := case when a_value is null then cast (null as json_element_t ) else json_element_t.parse(json_query(a_value, '$' returning clob)) end;
l_value json_element_t := ut_compound_data_helper.get_json_object(a_value);
begin
init(l_value);
return;
Expand Down
6 changes: 4 additions & 2 deletions test/ut3_user/expectations/test_expectations_json.pkb
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,8 @@ create or replace package body test_expectations_json is
ut.expect(ut3_tester_helper.main_helper.get_failed_expectations_num).to_equal(0);
end;


$if dbms_db_version.version >= 21 $then

procedure success_on_same_data_njson
as
l_actual json;
Expand Down Expand Up @@ -1781,6 +1782,7 @@ create or replace package body test_expectations_json is
--Assert
ut.expect(l_actual_message).to_be_like(l_expected_message);
end;


$end
end;
/
5 changes: 4 additions & 1 deletion test/ut3_user/expectations/test_expectations_json.pks
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ create or replace package test_expectations_json is
--%test( Compare two json arrays )
procedure check_json_arrays;

$if dbms_db_version.version >= 21 $then

--%test(Gives success for identical data using native json for 21c and above)
procedure success_on_same_data_njson;

Expand All @@ -95,6 +97,7 @@ create or replace package test_expectations_json is

--%test( Fail Json object not to have count using native json for 21c and above)
procedure fail_not_to_have_count_njson;


$end
end;
/
0