GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support native JSON data type of Oracle Database 21c · Issue #1114 · utPLSQL/utPLSQL

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

New issue
Copy link
New issue
Copy link
Closed
#1181
Closed
Support native JSON data type of Oracle Database 21c#1114
#1181
Copy link
Assignees
lwasylow
Labels
enhancement

Description

@PhilippSalvisberg
PhilippSalvisberg
opened on Dec 13, 2020
Issue body actions

Is your feature request related to a problem? Please describe

The Oracle Database 21c provides a native JSON data type in binary format. This data type can be used in tables, uses less space and is faster. See https://docs.oracle.com/en/database/oracle/oracle-database/21/adjsn/json-in-oracle-database.html#GUID-CBEDC779-39A3-43C9-AF38-861AE3FC0AEC

utPLSQL should support this data type similar as JSON_ELEMENT_T.

Currently the use of the native JSON data type leads to a runtime error.

Describe the solution you'd like

The following code

create table t (
   id     integer primary key,
   value  json
);

insert into t values (1, '{"a":"value a"}');
insert into t values (2, '{"a":"value a2"}');
commit;

declare
   l_actual sys_refcursor;
   l_expected sys_refcursor;
begin
   open l_actual for select value from t where id = 1;
   open l_expected for select value from t where id = 2;
   ut.expect(l_actual).to_equal(l_expected);
end;
/

should produce this result:

FAILURE
  Actual: json was expected to equal: json
  Diff: 1 differences found
  1 unequal values
    Actual value: "value a" was expected to be: "value a2" on path: $."a"

currently this code produces the following runtime error:

Error report -
ORA-01403: no data found
ORA-06512: at "UT3.UT_DATA_VALUE_REFCURSOR", line 113
ORA-06512: at "UT3.UT_COMPOUND_DATA_HELPER", line 620
ORA-06512: at "UT3.UT_CURSOR_DETAILS", line 111
ORA-06512: at "UT3.UT_DATA_VALUE_REFCURSOR", line 94
ORA-06512: at "UT3.UT_DATA_VALUE_REFCURSOR", line 22
ORA-06512: at "UT3.UT", line 83
ORA-06512: at line 7
01403. 00000 -  "no data found"
*Cause:    No data was found from the objects.
*Action:   There was no data from the objects which may be due to end of fetch.

Describe alternatives you've considered

As a workaround, you can manually convert the JSON data type to JSON_ELEMENT_T for the comparison.

Here's an example:

declare
   l_actual json_element_t;
   l_expected json_element_t;
   l_json json;
begin
   select value into l_json from t where id = 1;
   l_actual := json_element_t.parse(json_query(l_json, '$' returning clob));
   select value into l_json from t where id = 2;
   l_expected := json_element_t.parse(json_query(l_json, '$' returning clob));
   ut.expect(l_actual).to_equal(l_expected);
end;
/

As you see the code for JSON_ELEMENT_T could be reused to compare binary JSON data types. It should also possible to compare JSON_ELEMENT_T with a JSON.

Activity

  1. PhilippSalvisberg
    added
    enhancement
    on Dec 13, 2020
  2. lwasylow commented on Jan 30, 2022

    @lwasylow
    lwasylow
    on Jan 30, 2022
    Member
    More actions

    Given your workaround @PhilippSalvisberg I'm thinking best and simplest solution would be to add another override for json matcher accepting a new json type. This would have to been conditional compilation om this version. @jgebal what you think.

  3. lwasylow
    self-assigned this
    on Jan 30, 2022
  4. lwasylow
    linked a pull request that will close this issueSupport native JSON data type of Oracle Database 21c #1181on Feb 1, 2022
  5. lwasylow
    closed this as completedin #1181on Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @lwasylow
    lwasylow

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.