Обсуждение: Postgres jsonb data

Поиск
Список
Период
Сортировка

Postgres jsonb data

От
PG Doc comments form
Дата:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/datatype-json.html
Description:

Documentation suggests that a json type of null doesn't turn into anything
when read into a jsonb, because the json type of null doesn't correspond to
the postgres type of NULL.  We've found that in fact it's treated the same
as the string "null" - and the documentation probably should reflect this
edge case.
We're currently using Postgres 14, and it's possible that this has changed
in later versions, but I'm using the Postgres 14 documentation - and this is
table 8.23 in that version of the documentation (formatting doesn't copy
from the webpage into this form):
Table 8.23. JSON Primitive Types and Corresponding PostgreSQL Types
JSON primitive type     PostgreSQL type Notes
string  text    \u0000 is disallowed, as are Unicode escapes representing
characters not available in the database encoding
number  numeric NaN and infinity values are disallowed
boolean boolean Only lowercase true and false spellings are accepted
null    (none)  SQL NULL is a different concept

Re: Postgres jsonb data

От
Laurenz Albe
Дата:
On Tue, 2025-05-20 at 13:41 +0000, PG Doc comments form wrote:
> Page: https://www.postgresql.org/docs/14/datatype-json.html
>
> Documentation suggests that a json type of null doesn't turn into anything
> when read into a jsonb, because the json type of null doesn't correspond to
> the postgres type of NULL.  We've found that in fact it's treated the same
> as the string "null" - and the documentation probably should reflect this
> edge case.

I see them treated differently:

SELECT 'null'::jsonb IS NULL;
 ?column?
══════════
 f
(1 row)

Can you show examples of what you mean?

Yours,
Laurenz Albe