potential bug in JSON

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: potential bug in JSON
Date: 2013-05-28 15:38:57
Message-ID: CAFjNrYu_DVc7a5W_bFGBXREYL+vjurDq0aEw8TATECGWSZp6wQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2013-05-28 15:49:44 Re: Extent Locks
Previous Message Greg Smith 2013-05-28 15:36:49 Re: fallocate / posix_fallocate for new WAL file creation (etc...)