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

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Cast jsonb to numeric, int, float, bool
Дата
Msg-id 24822.1525789657@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Cast jsonb to numeric, int, float, bool  (Teodor Sigaev <teodor@sigaev.ru>)
Ответы Re: Cast jsonb to numeric, int, float, bool  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Teodor Sigaev <teodor@sigaev.ru> writes:
> Does anybody have an objections to patch?

1) Does this really pass muster from the translatability standpoint?
I doubt it.  I'd expect the translation of "cannot cast jsonb string
to int4" to use a translated equivalent of "string", but this code will
not do that.  You can't really fix it by gettext'ing the result of
JsonbTypeName, either, because then you're breaking the rule about not
assembling translated strings from components.

2) Our usual convention for type names that are written in error messages
is to use the SQL-standard names, that is "integer" and "double precision"
and so on.  For instance, float8in and int4in do not use the internal type
names in their messages:

regression=# select 'bogus'::float8;
ERROR:  invalid input syntax for type double precision: "bogus"
LINE 1: select 'bogus'::float8;
               ^
regression=# select 'bogus'::int4;
ERROR:  invalid input syntax for integer: "bogus"
LINE 1: select 'bogus'::int4;
               ^

So I think you made the wrong choices in jsonb_int4 etc.

            regards, tom lane


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

Предыдущее
От: Andreas Karlsson
Дата:
Сообщение: Re: MAP syntax for arrays
Следующее
От: Tom Lane
Дата:
Сообщение: Re: cannot drop replication slot if server is running in single-user mode