From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Paulo Vieira <paulovieira(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #13533: jsonb_populate_record does not work when the value is a simple string |
Date: | 2015-08-05 00:40:02 |
Message-ID: | CAKFQuwar_71OGRTQxrNdmUFsYsdorpM6AcxHPhw8m+XhhWuBrA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tue, Aug 4, 2015 at 5:19 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Paulo Vieira <paulovieira(at)gmail(dot)com> writes:
> > On Mon, Aug 3, 2015 at 5:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> This does not seem like a bug, because the value of the data field is
> >> just abc, and that isn't JSON. You'd need something more like
> >>
> >> input_data json := '{"id": 1, "data": "\"abc\""}';
>
> > I'm confused. In my example the value is <double quotes>abc<double
> quotes>,
> > which is a valid json value (and not simply abc).
>
> No, the value of the field is just abc --- the quotes are JSON syntax
> decoration, they are not part of the represented value. If we do it
> as you seem to have in mind, it would be impossible to deal sanely
> with data values that contain quotes or backslashes.
>
>
Paulo,
Consider what is stored if you define data as type text. The resultant
value would not include the double-quotes.
The following query fails and for the same reason.
SELECT 'abc'::json
More abstractly:
'{"id": <literal number>, "data": "<literal string>"}'
The value of the <literal string> is what is going to be parsed and so it
must be whatever is needed to make the following pseudo-code succeed.
SELECT <literal string>::json;
HTH,
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2015-08-05 01:20:51 | Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present) |
Previous Message | Tom Lane | 2015-08-05 00:19:34 | Re: BUG #13533: jsonb_populate_record does not work when the value is a simple string |