Re: BUG #9519: Allows storing scalar json, but fails when querying
От | David Johnston |
---|---|
Тема | Re: BUG #9519: Allows storing scalar json, but fails when querying |
Дата | |
Msg-id | 1394486056457-5795451.post@n5.nabble.com обсуждение исходный текст |
Ответ на | Re: BUG #9519: Allows storing scalar json, but fails when querying (John R Pierce <pierce@hogranch.com>) |
Список | pgsql-bugs |
John R Pierce wrote > On 3/10/2014 1:39 PM, Alf Kristian St=C3=B8yle wrote: >> This is the "unfortunate" part: >> /select data->>'foo' from jtest; >> =3D> ERROR: cannot extract element from a scalar >> / >> So either, only accept JSON object (not simple JSON values), or make=20 >> the JSON query operators work with JSON values as well. >=20 > the json ->> 'fieldname' operator has no meaning when applied to a=20 > scalar value. what would you suggest it should do? return a NULL ? "key does not exist" is represented by NULL if the operator is applied to a= n object so, in theory, since the key does not exist in a scalar the same value - NULL - would not be unexpected. From a theory perspective, and based upon typical database normalization rules, the current behavior makes the most sense but it does force the user to be consistent in defining of their JSON models - a little big-brother-is= h but if you are only going to support a single set of rules the more-strict ones are generally preferable. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-9= 519-Allows-storing-scalar-json-but-fails-when-querying-tp5795417p5795451.ht= ml Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
В списке pgsql-bugs по дате отправления: