Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WN7Pw-0003xg-VL for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Mar 2014 21:07:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WN7Pw-0001tj-C5 for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Mar 2014 21:07:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WN7Pv-0001ta-AT for pgsql-bugs@postgresql.org; Mon, 10 Mar 2014 21:07:23 +0000 Received: from hogranch.com ([75.101.82.47]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WN7Pm-0007l7-VK for pgsql-bugs@postgresql.org; Mon, 10 Mar 2014 21:07:23 +0000 Received: from [192.168.0.2] (porker [192.168.0.2]) by hogranch.com (8.11.6/8.11.6) with ESMTP id s2AL78e02885 for ; Mon, 10 Mar 2014 14:07:08 -0700 Message-ID: <531E2977.7060002@hogranch.com> Date: Mon, 10 Mar 2014 14:07:03 -0700 From: John R Pierce User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Re: BUG #9519: Allows storing scalar json, but fails when querying References: <20140310150952.398.53642@wrigleys.postgresql.org> <531E17E1.9020009@joh.to> In-Reply-To: Content-Type: multipart/alternative; boundary="------------060107040300010808010802" X-HawgScanner-Information: Please contact the ISP for more information X-HawgScanner: Found to be clean X-Pg-Spam-Score: -1.9 (-) 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 This is a multi-part message in MIME format. --------------060107040300010808010802 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit On 3/10/2014 1:39 PM, Alf Kristian Støyle wrote: > This is the "unfortunate" part: > /select data->>'foo' from jtest; > => ERROR: cannot extract element from a scalar > / > So either, only accept JSON object (not simple JSON values), or make > the JSON query operators work with JSON values as well. the json ->> 'fieldname' operator has no meaning when applied to a scalar value. what would you suggest it should do? return a NULL ? -- john r pierce 37N 122W somewhere on the middle of the left coast --------------060107040300010808010802 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 3/10/2014 1:39 PM, Alf Kristian Støyle wrote:
This is the "unfortunate" part:
select data->>'foo' from jtest;
=> ERROR:  cannot extract element from a scalar

So either, only accept JSON object (not simple JSON values), or make the JSON query operators work with JSON values as well.

the json ->> 'fieldname' operator has no meaning when applied to a scalar value.    what would you suggest it should do?   return a NULL ?



-- 
john r pierce                                      37N 122W
somewhere on the middle of the left coast
--------------060107040300010808010802--