Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UliiJ-00068T-S0 for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Jun 2013 16:43:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UliiJ-0008Mi-Al for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Jun 2013 16:43:31 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UlhIK-00043x-L7 for pgsql-bugs@postgresql.org; Sun, 09 Jun 2013 15:12:36 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UlhIE-0002n6-Q0 for pgsql-bugs@postgresql.org; Sun, 09 Jun 2013 15:12:36 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UlhID-0006pv-SE for pgsql-bugs@postgresql.org; Sun, 09 Jun 2013 15:12:30 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1UlhI8-0000bi-Ln for pgsql-bugs@postgresql.org; Sun, 09 Jun 2013 15:12:24 +0000 Date: Sun, 09 Jun 2013 15:12:24 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #8218: Error when querying an JSON data, 9.3beta To: pgsql-bugs@postgresql.org From: daniel.zlatev@gmail.com X-Pg-Spam-Score: 1.6 (+) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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:=20=20=20=20=20=20=20=20 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 --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs