Re: Cast jsonb to numeric, int, float, bool

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Cast jsonb to numeric, int, float, bool
Дата
Msg-id 2087.1525792633@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Cast jsonb to numeric, int, float, bool  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Cast jsonb to numeric, int, float, bool  (Teodor Sigaev <teodor@sigaev.ru>)
Список pgsql-hackers
I wrote:
> 1) Does this really pass muster from the translatability standpoint?
> I doubt it.

After further thought about that, it seems that what we typically don't
try to translate is SQL-standard type names, that is, error messages
along the line of "blah blah blah type %s" are considered fine.  So
the problem here is that you factorized the error reporting poorly.
I think you want the callers to look like

     if (!JsonbExtractScalar(&in->root, &v) || v.type != jbvNumeric)
        cannotCastJsonbValue(v.type, "double precision");

where the subroutine contains the whole ereport() call, and its lookup
table entries are e.g.

    gettext_noop("cannot cast jsonb string to type %s")

            regards, tom lane


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

Предыдущее
От: Ildar Musin
Дата:
Сообщение: Re: MAP syntax for arrays
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: MAP syntax for arrays