Re: remaining sql/json patches
От | Himanshu Upadhyaya |
---|---|
Тема | Re: remaining sql/json patches |
Дата | |
Msg-id | CAPF61jCV9apT4xHgWFXKZx1U+=TZOJEuO+7udRmmJLpVNHFKdQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: remaining sql/json patches (jian he <jian.universality@gmail.com>) |
Ответы |
Re: remaining sql/json patches
|
Список | pgsql-hackers |
I have tested a nested case but why is the negative number allowed in subscript(NESTED '$.phones[-1]'COLUMNS), it should error out if the number is negative.
‘postgres[170683]=#’SELECT * FROM JSON_TABLE(jsonb '{
‘...>’ "id" : "0.234567897890",
‘...>’ "name" : { "first":"Johnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn", "last":"Doe" },
‘...>’ "phones" : [{"type":"home", "number":"555-3762"},
‘...>’ {"type":"work", "number":"555-7252", "test":123}]}',
‘...>’ '$'
‘...>’ COLUMNS(
‘...>’ id numeric(2,2) PATH 'lax $.id',
‘...>’ last_name varCHAR(10) PATH 'lax $.name.last', first_name VARCHAR(10) PATH 'lax $.name.first',
‘...>’ NESTED '$.phones[-1]'COLUMNS (
‘...>’ "type" VARCHAR(10),
‘...>’ "number" VARCHAR(10)
‘...>’ )
‘...>’ )
‘...>’ ) as t;
id | last_name | first_name | type | number
------+-----------+------------+------+--------
0.23 | Doe | Johnnnnnnn | |
(1 row)
‘...>’ "id" : "0.234567897890",
‘...>’ "name" : { "first":"Johnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn", "last":"Doe" },
‘...>’ "phones" : [{"type":"home", "number":"555-3762"},
‘...>’ {"type":"work", "number":"555-7252", "test":123}]}',
‘...>’ '$'
‘...>’ COLUMNS(
‘...>’ id numeric(2,2) PATH 'lax $.id',
‘...>’ last_name varCHAR(10) PATH 'lax $.name.last', first_name VARCHAR(10) PATH 'lax $.name.first',
‘...>’ NESTED '$.phones[-1]'COLUMNS (
‘...>’ "type" VARCHAR(10),
‘...>’ "number" VARCHAR(10)
‘...>’ )
‘...>’ )
‘...>’ ) as t;
id | last_name | first_name | type | number
------+-----------+------------+------+--------
0.23 | Doe | Johnnnnnnn | |
(1 row)
Thanks,
Himanshu
В списке pgsql-hackers по дате отправления: