Add support for BOOLEAN, JSON, VECTOR data types introduced in Oracle Database 23ai #1344
Replies: 10 comments
-
|
This can be a really exciting addition to utPLSQL. I will be happy to spend time implementing it, |
Beta Was this translation helpful? Give feedback.
-
|
Hello @PhilippSalvisberg /@jgebal, I am a bit new to Git and having some experience in using PLSQL. I would be happy to contribute in this new feature. It would be helpful if you can guide me or assign me a task so that i can work on it. Also, if you need any help in any of the other issues also please let me know. I would really appreciate your insights and guidance here. Thanks and Regards, |
Beta Was this translation helpful? Give feedback.
-
@amithdas99 Thanks for your interest in contributing to the utPLSQL project. Please join the Slack channel to discuss non-issue-related stuff. See https://github.com/utPLSQL/utPLSQL/blob/develop/readme.md#contributing-to-the-project regarding details on how to contribute and how to join the slack channel. Thanks. |
Beta Was this translation helpful? Give feedback.
-
|
@PhilippSalvisberg I assume, that the requirement would be to assure that utPLSQL can support those datatypes inside a cursor comparison. |
Beta Was this translation helpful? Give feedback.
-
|
@amithdas99 Maybe some other, smaller issues, would be a good starting point. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you both @jgebal and @PhilippSalvisberg !! |
Beta Was this translation helpful? Give feedback.
-
I would recommend starting with #1161 |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I understand your question. However, maybe the following experiment I ran on an Oracle Database 23ai version 23.5 may help understand how the new data types can be used in SQL and PL/SQL. drop table if exists t;
create table t (
c1 boolean,
c2 json,
c3 vector
);
insert into t (c1, c2, c3)
values(true, json('[{"name":"test", "value":"hello"}]'), vector('[0,2,2,0,0]'));
set serveroutput on size unlimited
declare
l_c1 boolean;
l_c2 json;
l_c3 vector;
l_row t%rowtype;
begin
for r in (select c1, c2, c3 from t) loop
dbms_output.put_line('explicitly defined types in PL/SQL');
l_c1 := r.c1; -- converts SQL boolean to PL/SQL boolean
l_c2 := r.c2;
l_c3 := r.c3;
dbms_output.put_line('l_c1: ' || case when l_c1 then 1 else 0 end);
dbms_output.put_line('l_c2: ' || json_serialize(l_c2));
dbms_output.put_line('l_c3: ' || vector_serialize(l_c3));
dbms_output.put_line(null);
dbms_output.put_line('implicitly defined types via %rowtype');
l_row := r;
dbms_output.put_line('l_row.c1: ' || case when l_row.c1 then 1 else 0 end);
dbms_output.put_line('l_row.c2: ' || json_serialize(l_row.c2));
dbms_output.put_line('l_row.c3: ' || vector_serialize(l_row.c3));
end loop;
end;
/and the output is: |
Beta Was this translation helpful? Give feedback.
-
|
Thank you @PhilippSalvisberg So it seems like there will be even more work. PL/SQL BOOLEAN datatype is already supported by utPLSQL.
Additionally I would throw in XMLTYPE to the mix as it son not natively supported by utPLSQL.
|
Beta Was this translation helpful? Give feedback.
-
After closing this issue, I expect the following code to work without throwing an exception. drop table if exists t;
create table t (
c1 boolean,
c2 json,
c3 vector
);
insert into t (c1, c2, c3)
values(true, json('[{"name":"test", "value":"hello"}]'), vector('[0,2,2,0,0]'));
set serveroutput on size unlimited
<<does_not_work_in_utplsql_3_1_14>>
declare
c_actual sys_refcursor;
c_expected sys_refcursor;
begin
open c_actual for select * from t;
open c_expected for select * from (values (true, json('[{"name":"test", "value":"hello"}]'), vector('[0,2,2,0,0]'))) as t (c1, c2, c3);
ut.expect(c_actual).to_equal(c_expected);
end does_not_work_in_utplsql_3_1_14;
/
<<workaround_with_utplsql_3_1_14>>
declare
c_actual sys_refcursor;
c_expected sys_refcursor;
begin
open c_actual for select case when c1 then 1 else 0 end as c1, json_serialize(c2) as c2, vector_serialize(c3) as c3 from t;
open c_expected for select * from (values (1, '[{"name":"test","value":"hello"}]', '[0,2.0E+000,2.0E+000,0,0]')) as t (c1, c2, c3);
ut.expect(c_actual).to_equal(c_expected);
end workaround_with_utplsql_3_1_14;
/The output with 3.1.14 looks like this: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
I'm also using Oracle Database 23ai and would like to assert the new data types provided in this version. For that the documented support of data types needs to be extend by the following data types:
Describe the solution you'd like
The supported data types should be extended as follows
booleanbe_not_null,be_null,be_false,be_true,equalbooleanjsonbe_not_null,be_null,equal,be_empty,have_countvectorbe_not_null,be_null,equal,contain,be_empty,have_countnested table/varrayFor the
jsondata type thecontainmatcher might be sensible when the JSON is an array. Furthermore, I can imagine some additional matchers forvector. However, I'd start with a shorter list and handle new matchers in a dedicated issue when needed.Beta Was this translation helpful? Give feedback.
All reactions