Json:- Accepting 'integer' value

Started by shaurya jainalmost 5 years ago2 messagesgeneral
Jump to latest
#1shaurya jain
12345shaurya@gmail.com

Hi Team,

Postgres Version:- 12.7
Issue:- JSON data type column accepting 'integer' value
Priority:-Minor

Below is the table definition and insert statement, which is working in
Postgres however it doesn't work in oracle with check constraint(jj is JSON
strict).

postgres=# \d kp
Table "public.kp"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+--------------------------------
id | integer | | not null | nextval('kp_id_seq'::regclass)
jj | json | | |

postgres=# insert into kp(jj) values('98');
INSERT 0 1

But while we checking the same thing in Oracle it doesn't accept this. Is
it an issue with Postgres data type?

--
Thanks and Regards,
Shaurya Jain
email:- 12345shaurya@gmail.com
*Mobile:- +91-8802809405*
LinkedIn:- https://www.linkedin.com/in/shaurya-jain-74353023

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: shaurya jain (#1)
Re: Json:- Accepting 'integer' value

shaurya jain <12345shaurya@gmail.com> writes:

But while we checking the same thing in Oracle it doesn't accept this. Is
it an issue with Postgres data type?

I'd call it an issue with Oracle.

We follow RFC 7159, which specifies that "bare" scalars (numbers,
strings, booleans) are valid JSON values. I see though that it
says

A JSON text is a serialized value. Note that certain previous
specifications of JSON constrained a JSON text to be an object or an
array.

so apparently Oracle is following some obsolete version of the spec.

regards, tom lane