From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: '{"x": 42, "y": null}'::jsonb != '{"x": 42}'::jsonb ... Really?
Date: Mon, 20 Jun 2022 00:30:44 +0200
Message-ID: <2ced3259-2cb5-9ecc-3157-69b6cd3f51c8@gmx.net> (raw)
In-Reply-To: <7E0BF7DF-CC12-48B6-8550-9C2B5A8F78B1@yugabyte.com>
References: <7E0BF7DF-CC12-48B6-8550-9C2B5A8F78B1@yugabyte.com>
Bryn Llewellyn schrieb am 04.06.2022 um 03:41:
> Am I missing a use case where an object with a key-value pair with a
> JSON null value is meaningfully different from one where the key is
> simply absent?
It seems the JSON specification doesn't actually define equality.
But the JSON patch RFC 6902[1] defines the equality of two objects
as:
objects: are considered equal if they contain the same number of
members, and if each member can be considered equal to a member in
the other object, by comparing their keys (as strings) and their
values (using this list of type-specific rules).
As {"x": 42, "y": null} and {"x": 42} do not contain the same number
of members, I think Postgres' behaviour is correct.
Thomas
[1] https://www.rfc-editor.org/rfc/rfc6902#section-4.6
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: shammat@gmx.net
Subject: Re: '{"x": 42, "y": null}'::jsonb != '{"x": 42}'::jsonb ... Really?
In-Reply-To: <2ced3259-2cb5-9ecc-3157-69b6cd3f51c8@gmx.net>
References: <7E0BF7DF-CC12-48B6-8550-9C2B5A8F78B1@yugabyte.com> <2ced3259-2cb5-9ecc-3157-69b6cd3f51c8@gmx.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox