BUG #9519: Allows storing scalar json, but fails when querying - Mailing list pgsql-bugs

From alf.kristian@gmail.com
Subject BUG #9519: Allows storing scalar json, but fails when querying
Date
Msg-id 20140310150952.398.53642@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #9519: Allows storing scalar json, but fails when querying  (Marko Tiikkaja <marko@joh.to>)
Re: BUG #9519: Allows storing scalar json, but fails when querying  (Jeff Janes <jeff.janes@gmail.com>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      9519
Logged by:          Alf Kristian Støyle
Email address:      alf.kristian@gmail.com
PostgreSQL version: 9.3.2
Operating system:   Red Hat 4.6.3-2
Description:

Steps to reproduce:
create table jtest (data json);
=> CREATE TABLE

insert into jtest (data) values ('1');
=> INSERT 0 1

select data->>'foo' from jtest;
=> ERROR:  cannot extract element from a scalar


I think the insert should fail, since '1' is not valid JSON.

After the data is in the database every query using the ->> operator,
hitting the row containing '1' will fail.

Our database runs in Amazon RDS, 'select version();' returns:
PostgreSQL 9.3.2 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.6.3
20120306 (Red Hat 4.6.3-2), 64-bit

pgsql-bugs by date:

Previous
From: Mike Blackwell
Date:
Subject: Re: BUG #9518: temporary login failure - "missing pg_hba entry"
Next
From: Marko Tiikkaja
Date:
Subject: Re: BUG #9519: Allows storing scalar json, but fails when querying