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

Поиск
Список
Период
Сортировка
От Vik Fearing
Тема Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.
Дата
Msg-id b18a78a4-f2be-d783-3e62-6ba487fe0545@postgresfriends.org
обсуждение исходный текст
Ответ на Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.  (Bryn Llewellyn <bryn@yugabyte.com>)
Список pgsql-hackers
On 15/02/2020 04:07, Bryn Llewellyn wrote:
> This:
> 
> select jsonb_pretty(jsonb_build_object(
>  'a'::varchar, 1.7::numeric,
>  'b'::varchar, 'dog'::varchar,
>  'c'::varchar, true::boolean
>  ))
> 
> allows me to express what I want. That’s a good thing. Are you saying that this:
> 
> select jsonb_pretty(jsonb_object(
>  '{a, 17, b, "dog", c, true}'::varchar[]
>  ))
> 
> simply lacks that power of expression and that every item in the array is assumed to be intended to end up as a JSON
textprimitive value? In other words, do the double quotes around "dog" have no effect?
 

That is correct.

> That would be a bad thing—and it would limit the usefulness of the jsonb_object() function.

Use the long form if you need to mix datatypes.
-- 
Vik Fearing



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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: [HACKERS] Moving relation extension locks out of heavyweight lock manager
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: jsonb_object() seems to be buggy. jsonb_build_object() is good.