potential bug in JSON - Mailing list pgsql-hackers

From Szymon Guz
Subject potential bug in JSON
Date
Msg-id CAFjNrYu_DVc7a5W_bFGBXREYL+vjurDq0aEw8TATECGWSZp6wQ@mail.gmail.com
Whole thread Raw
Responses Re: potential bug in JSON  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
I've found a potential bug. Why the "->" operator returns JSON instead of TEXT? It doesn't make sens for me, and the documentation doesn't inform about that.

postgres=# SELECT ('{"id": 1}'::json -> 'id')::int;
ERROR:  cannot cast type json to integer
LINE 1: SELECT ('{"id": 1}'::json -> 'id')::int;

postgres=# SELECT ('{"id": 1}'::json -> 'id')::text::int;
 int4 
------
    1
(1 row)


postgres=# SELECT version();
                                                    version                                                    
---------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.3beta1 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3, 64-bit
(1 row)

pgsql-hackers by date:

Previous
From: Greg Smith
Date:
Subject: Re: fallocate / posix_fallocate for new WAL file creation (etc...)
Next
From: Merlin Moncure
Date:
Subject: Re: Extent Locks