Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.

Поиск
Список
Период
Сортировка
От Bryn Llewellyn
Тема Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.
Дата
Msg-id 6DD71055-396C-4A8D-8BA8-1A3B620BE7A6@yugabyte.com
обсуждение исходный текст
Ответ на Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Список pgsql-hackers
On 16-Feb-2020, at 16:40, Andrew Dunstan <andrew.dunstan@2ndquadrant.com> wrote:

On 2/16/20 7:25 PM, Bryn Llewellyn wrote:
>
> B.t.w., you earlier said “The double quotes  [around “dog”] serve a specific purpose, to allow values containing
commasto be treated as a single value (see syntax details for the exact rules) in the resulting array of text values.”
Butthis test shows that they are not needed for that purpose: 


I didn't say that. Someone else did.


>
> select jsonb_pretty(jsonb_object(
>  '{a, 17, b, dog house, c, true}'::varchar[]
>  ))
>
> This is the result:
>
> {                    +
>     "a": "17",       +
>     "b": "dog house",+
>     "c": "true"      +
> }
>
> The commas are sufficient separators.
>
> It seems to me, therefore, that writing the double quotes gives the wrong message: they make it look like you are
indeedspecifying a text value rather than a numeric or integer value. But we know that the double quotes do *not*
achievethis. 
>


No, you haven't understood what they said. If the field value contains a
comma it needs to be quoted. But none of the fields in your example do.
If your field were "dog,house" instead of "dog house" it would need to
be quoted. This had nothing to do with json, BTW, it's simply from the
rules for array literals.

Bryn replied:

Got it! Thanks for helping me out, Andrew.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: Conflict handling for COPY FROM
Следующее
От: Kasahara Tatsuhito
Дата:
Сообщение: Re: small improvement of the elapsed time for truncating heap in vacuum