From: daniel.zlatev@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #8218: Error when querying an JSON data, 9.3beta
Date: Sun, 09 Jun 2013 15:12:24 +0000
Message-ID: <E1UlhI8-0000bi-Ln@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 8218
Logged by: Daniel Zlatev
Email address: daniel.zlatev@gmail.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: daniel.zlatev@gmail.com
Subject: Re: BUG #8218: Error when querying an JSON data, 9.3beta
In-Reply-To: <E1UlhI8-0000bi-Ln@wrigleys.postgresql.org>
References: <E1UlhI8-0000bi-Ln@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox