BUG #8218: Error when querying an JSON data, 9.3beta

From: daniel(dot)zlatev(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8218: Error when querying an JSON data, 9.3beta
Date: 2013-06-09 15:12:24
Message-ID: E1UlhI8-0000bi-Ln@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8218
Logged by: Daniel Zlatev
Email address: daniel(dot)zlatev(at)gmail(dot)com
PostgreSQL version: Unsupported/Unknown
Operating system: Windows
Description:

Dears,

today I was playing with some JSON data, and I have noticed something
strange.

1. I've created the follwing table:
CREATE TABLE products (
data JSON
);

2. Then inserting some data:
INSERT INTO products(data) VALUES('{"id": 1, "name": "shoes", "in_stock":
5}');
INSERT INTO products(data) VALUES('[1,2,3,4,5]');

3. Then i've run this SELECT statement
SELECT * FROM products WHERE (data->>'in_stock')::integer > 0

Output was:
[Err] ERROR: cannot extract field from a non-object

I can understand the reason behind this error(JSON array don't has fields),
but for me it is very logical postgres to exclude this row from the
returning set, rather to throw an error.

So that is it.

Best regards
Daniel

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2013-06-09 17:24:26 Re: BUG #8218: Error when querying an JSON data, 9.3beta
Previous Message Isaac Morland 2013-06-07 13:43:30 Re: BUG #8215: pg_dump includes table out of order in SQL dump