Re: Cast jsonb to numeric, int, float, bool - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Cast jsonb to numeric, int, float, bool
Date
Msg-id 24822.1525789657@sss.pgh.pa.us
Whole thread Raw
In response to Re: Cast jsonb to numeric, int, float, bool  (Teodor Sigaev <teodor@sigaev.ru>)
Responses Re: Cast jsonb to numeric, int, float, bool  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: Andreas Karlsson
Date:
Subject: Re: MAP syntax for arrays
Next
From: Tom Lane
Date:
Subject: Re: cannot drop replication slot if server is running in single-user mode