From: David Johnston <polobo@yahoo.com>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #9519: Allows storing scalar json, but fails when querying
Date: Tue, 11 Mar 2014 08:47:17 -0700 (PDT)
Message-ID: <1394552837877-5795536.post@n5.nabble.com> (raw)
In-Reply-To: <20140311075030.GC9524@defunct.ch>
References: <20140310150952.398.53642@wrigleys.postgresql.org>
<531E17E1.9020009@joh.to>
<CA+tXr--Z7ap5mcaBVNKOi9NXd2MaZG9FO4t7cVj3cCMZjz+g6g@mail.gmail.com>
<1394485742473-5795449.post@n5.nabble.com>
<20140311075030.GC9524@defunct.ch>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Christian Kruse-4 wrote
> Hi,
>
> On 10/03/14 14:09, David Johnston wrote:
>
>> The system supposes that, at a structural level, you are dealing with
>> column-consistent data and so if you ask for something that does not make
>> sense (i.e., an object key when you have an array or a scalar) it will
>> warn
>> you.
>
> Looking at the common usage of JSON it doesn't seem to be a good idea
> to imply column-consistent JSON. Normally when JSON is used the
> application ensures consistency and when a non-existent key is
> accessed NULL is returned. I think this is expected behavior and we
> should do it like that, too; if one wants it different, he should use
> CHECK constraints.
The database is the application. It's job is to store data so that,
multiple, other applications can access it and in such a way that those
applications do not have to enforce data integrity since the database has
taken care of that responsibility.
I can see it both ways and so maybe a set of null-returning functions and
operators need to be made standard so the user can choose which behavior is
desired. I cannot see changing the behavior of the current operators since
these are in the wild - though turning errors into non-errors isn't really a
risk since no existing code can reasonably be said to rely on such behavior.
The advantage of avoiding data-specific errors is probably worth it. It
makes finding problems harder, not easier, to locate if one doesn't make
liberal use of check constraints but personally I'd rather have some wrong
data interspersed with the good data instead of throwing out al the data
because one single value is bad - a value that may never make it to the
final result anyway.
David J.
--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-9519-Allows-storing-scalar-json-but-fails-when-querying-...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
--
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: polobo@yahoo.com
Subject: Re: BUG #9519: Allows storing scalar json, but fails when querying
In-Reply-To: <1394552837877-5795536.post@n5.nabble.com>
References: <20140310150952.398.53642@wrigleys.postgresql.org> <531E17E1.9020009@joh.to> <CA+tXr--Z7ap5mcaBVNKOi9NXd2MaZG9FO4t7cVj3cCMZjz+g6g@mail.gmail.com> <1394485742473-5795449.post@n5.nabble.com> <20140311075030.GC9524@defunct.ch> <1394552837877-5795536.post@n5.nabble.com>
* 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