Re: JSON manipulation functions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: JSON manipulation functions
Дата
Msg-id 6547.1274988907@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: JSON manipulation functions  (Joseph Adams <joeyadams3.14159@gmail.com>)
Ответы Re: JSON manipulation functions  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Joseph Adams <joeyadams3.14159@gmail.com> writes:
> I tried making a function named json_type that has the same name as
> the type json_type.  However, this doesn't work as expected:

> SELECT json_type('[1,2,3]');

> Instead of calling json_type with '[1,2,3]' casted to JSON, it's
> trying to cast '[1,2,3]' to json_type.  Is there a way to override
> this behavior, or would I be better off renaming the function?

Well, that might not be the behavior you expected, but that doesn't
make it wrong.  The above is, by convention, equivalent to
'[1,2,3]'::json_type, so it's acting as per convention.

If the function is a cast function (which it is), it *should* be named
after the destination type.  Doing anything else will violate numerous
longstanding expectations.  You might want to read the comments about
function-calls-as-casts in func_get_detail().
        regards, tom lane


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: [9.1] pg_stat_get_backend_server_addr
Следующее
От: Robert Haas
Дата:
Сообщение: Re: JSON manipulation functions