Re: SQL/JSON: functions

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема Re: SQL/JSON: functions
Дата
Msg-id 26a0cef6-f2f5-3b93-0dd5-eda434d2e189@dunslane.net
обсуждение исходный текст
Ответ на Re: SQL/JSON: functions  (Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>)
Список pgsql-hackers
On 1/4/22 04:18, Himanshu Upadhyaya wrote:
> On Thu, Dec 16, 2021 at 3:06 AM Andrew Dunstan <andrew@dunslane.net> wrote:
>>
>>
>> SELECT JSON_OBJECTAGG(k: v ABSENT ON NULL) AS apt
>> FROM (VALUES ('no', 5), ('area', 50), ('rooms', 2), ('foo', NULL),
>> (5,5)) kv(k, v);
>> ERROR:  22P02: invalid input syntax for type integer: "no"
>> LINE 2: FROM (VALUES ('no', 5), ('area', 50), ('rooms', 2), ('foo', ...
>>                       ^
>> LOCATION:  pg_strtoint32, numutils.c:320
>>
>> Above call to JSON_OBJECTAGG is failing because we have the numeric
>> key, is not that it also needs to follow the same context  of
>> converting key argument to text? or both(JSON_OBJECTAGG  and
>> JSON_OBJECT) should not allow numeric keys in the JSON object and
>> allow date (if that is the only use case)?
>>


this error has nothing at all to do with the json code. You simply have
an invalid VALUES expression:


postgres=# select * FROM (VALUES ('no', 5), ('area', 50), ('rooms', 2),
('foo', NULL), (5,5)) kv(k, v);
ERROR:  invalid input syntax for type integer: "no"
LINE 1: select * FROM (VALUES ('no', 5), ('area', 50), ('rooms', 2),...

cheers


andrew

-- 

Andrew Dunstan
EDB: https://www.enterprisedb.com




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dag Lem
Дата:
Сообщение: Re: daitch_mokotoff module
Следующее
От: Alexander Lakhin
Дата:
Сообщение: Index-only scan for btree_gist turns bpchar to char