From: | Brian Mendoza <brian(at)rotamap(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | JSONB operator unanticipated behaviour |
Date: | 2023-05-18 13:17:04 |
Message-ID: | CALWFwZ0GG_5fUCXfLMTMSZjO0VnrL=r2sHPJ_9Sr1623_5MP=w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I have encountered unanticipated behaviour with a JSONB operator, and
wanted to make sure I am not misunderstanding its intended use.
When using the @> operator, I get this result.
select '{"a": [1]}'::jsonb @> '{"a": []}'::jsonb;
?column?
----------
t
(1 row)
However, given the phrasing in the documentation, I would have expected
False.
"Does the left JSON value contain the right JSON path/value entries at the
top level?"
Particularly given the following:
select '[1]'::jsonb = '[]'::jsonb;
?column?
----------
f
(1 row)
So the keys are the same, the values (when compared directly) are not, but
@> returns True. Have I misunderstood the usage of the operator?
The above queries have been run on postgres 14, if that helps.
--
Brian Mendoza
brian(at)rotamap(dot)net
Rotamap
www.rotamap.net
020 7631 1555
3 Tottenham Street London W1T 2AF
Registered in England No. 04551928
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2023-05-18 14:35:08 | Re: Is there a good way to handle sum types (or tagged unions) in PostgreSQL? |
Previous Message | Victor Nordam Suadicani | 2023-05-18 12:27:27 | Is there a good way to handle sum types (or tagged unions) in PostgreSQL? |