Unexpected syntax error when using JSON -> in 9.3.5

Поиск
Список
Период
Сортировка
От Seamus Abshere
Тема Unexpected syntax error when using JSON -> in 9.3.5
Дата
Msg-id 5421961B.2060602@abshere.net
обсуждение исходный текст
Ответы Re: Unexpected syntax error when using JSON -> in 9.3.5  (David G Johnston <david.g.johnston@gmail.com>)
Re: Unexpected syntax error when using JSON -> in 9.3.5  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
hi all,

This part looks correct and expected:

> $ psql foobar
> psql (9.3.5)
> Type "help" for help.
>
> foobar=# select coalesce('{}'::json->'a', 1);
> ERROR:  COALESCE types json and integer cannot be matched
> LINE 1: select coalesce('{}'::json->'a', 1);
>                                          ^

but check it out when I use a string instead of an integer:

> foobar=# select coalesce('{}'::json->'a', 'b');
> ERROR:  invalid input syntax for type json
> LINE 1: select coalesce('{}'::json->'a', 'b');
>                                          ^
> DETAIL:  Token "b" is invalid.
> CONTEXT:  JSON data, line 1: b

That seems like the wrong error - shouldn't it be the equiv of "[...]
json and string cannot be matched"?

Thanks,
Seamus


--
Seamus Abshere, SCEA
https://github.com/seamusabshere


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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Question about Vacuum and Replication failures in 9.3.5
Следующее
От: Seamus Abshere
Дата:
Сообщение: Will there be a JSON operator like ->> but returning numeric?