You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the following sql script to creates required types, table and rows..
DROP USER T1 cascade
/
GRANT CONNECT, RESOURCE, UNLIMITED TABLESPACE TO T1 identified by oracle
/
ALTER SESSION set CURRENT_SCHEMA = T1
/
create or replace type ADDR_TYPE as OBJECT(
STREET_LINE_1 VARCHAR2(128),
STREET_LINE_2 VARCHAR2(128),
CITY VARCHAR2(128)
)
NOT FINAL NOT INSTANTIABLE
/
show errors
--
create or replace type US_ADDR_TYPE UNDER ADDR_TYPE (
STATE VARCHAR2(2),
ZIPCODE NUMBER(5)
)
NOT FINAL
/
show errors
--
create or replace type US_ZIP_PLUS4_TYPE UNDER US_ADDR_TYPE (
PLUS4 NUMBER(4)
)
/
show errors
--
create or replace type UK_ADDR_TYPE UNDER ADDR_TYPE(
COUNTY VARCHAR2(128),
POSTCODE VARCHAR2(10)
)
/
show errors
--
create type PERSON_TYPE as OBJECT(
NAME VARCHAR2(128),
ADDR ADDR_TYPE
)
/
show errors
--
create table PERSON_TABLE(
ID NUMBER(4),
DETAILS PERSON_TYPE
)
/
desc ADDR_TYPE
--
desc US_ADDR_TYPE
--
desc US_ZIP_PLUS4_TYPE
--
desc UK_ADDR_TYPE
--
insert into PERSON_TABLE values (1, PERSON_TYPE('James Bond',UK_ADDR_TYPE('1 ST JAMES PLACE','','LONDON','','SW1 23EF')))
/
insert into PERSON_TABLE values (2, PERSON_TYPE('Fred Flintsone',US_ZIP_PLUS4_TYPE('2 ROCK ST','BOULDERTOWN','ROCK VEGAS','CA',94521,1234)))
/
select *
from PERSON_TABLE
/
select ID, JSON_OBJECT(DETAILS)
from PERSON_TABLE
``
This should create a table with the following rows
SQL> select * from T1.PERSON_TABLE;
ID DETAILS(NAME, ADDR(STREET_LINE_1, STREET_LINE_2, CITY))
---------- ------------------------------------------------------------------------------------------------------------------------------------
1 PERSON_TYPE('James Bond', UK_ADDR_TYPE('1 ST JAMES PLACE', NULL, 'LONDON', NULL, 'SW1 23EF'))
2 PERSON_TYPE('Fred Flintsone', US_ZIP_PLUS4_TYPE('2 ROCK ST', 'BOULDERTOWN', 'ROCK VEGAS', 'CA', 94521, 1234))
SQL>
As you can see it has only output the attributes defined by the base type, it has not output the attributes defined by the sub-types. I would have expected it to output all the information. Another issue is should it also output the 'type' itself, so the program processing the data does not have to try to guess which type or subtype the data is an instance of.
sharadraju
changed the title
Object Serialization does not handle Type Heirarchies correcly
Object Serialization does not handle Type Hierarchies correctly
Oct 11, 2023
See https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html for how to report security issues.
With the async/await programming style, make sure you are using 'await' in the right places.
Is it an error or a hang or a crash?
error
What error(s) you are seeing?
Incorrect conversion of PL/SQL types to JSON
Include a runnable Node.js script that shows the problem.
Include all SQL needed to create the database schema. Use Markdown syntax, see https://help.github.com/github/writing-on-github/basic-writing-and-formatting-syntax
Run the following sql script to creates required types, table and rows..
This should create a table with the following rows
Now run the following node program
The output is
As you can see it has only output the attributes defined by the base type, it has not output the attributes defined by the sub-types. I would have expected it to output all the information. Another issue is should it also output the 'type' itself, so the program processing the data does not have to try to guess which type or subtype the data is an instance of.
18,19.20
The text was updated successfully, but these errors were encountered: