Zum Inhalt springen

Hinweise

Gleichheitsvergleich

Warning Der Gleichheitsvergleich von JSON-Werten kann derzeit je nach Kontext unterschiedlich ausfallen. In manchen Fällen basiert er auf einem Rohtextvergleich, in anderen auf einem logischen Inhaltsvergleich.

Die folgende Abfrage liefert für alle Felder true:

SELECT
a != b, -- Space is part of physical JSON content. Despite equal logical content, values are treated as not equal.
c != d, -- Same.
c[0] = d[0], -- Equality because space was removed from physical content of fields:
a = c[0], -- Indeed, field is equal to empty list without space...
b != c[0], -- ... but different from empty list with space.
FROM (
SELECT
'[]'::JSON AS a,
'[ ]'::JSON AS b,
'[[]]'::JSON AS c,
'[[ ]]'::JSON AS d
);
(a != b) (c != d) (c[0] = d[0]) (a = c[0]) (b != c[0])
true true true true true