Re: '{"x": 42, "y": null}'::jsonb != '{"x": 42}'::jsonb ... Really?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bryn Llewellyn <bryn(at)yugabyte(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: '{"x": 42, "y": null}'::jsonb != '{"x": 42}'::jsonb ... Really?
Date: 2022-06-07 15:09:02
Message-ID: CAHyXU0wayZrD1RGoSn-Z_VBirWqJ6jPGF04Z78w75ppcGdFyUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jun 4, 2022 at 12:37 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Bryn Llewellyn <bryn(at)yugabyte(dot)com> writes:
> > I'm going to try to think like this:
> > The number of possible spellings of the names of keys in a JSON object
> is some flavor of infinite. So including this in an object:
> > "k": null
> > really is saying something. It says that I do know about "k" and that
> yet I have simply no information available about its value.
>
> I'd read it as asserting that key "k" is meaningful for this object,
> but the correct value for that key is not known.
>
> I have a hard time with your assertion that {"x": 42, "y": null}
> should be considered equivalent to {"x": 42}, because it would
> render key-exists predicates useless. Either you have to say that
> key "y" is claimed to exist in both of these objects and indeed every
> object, or you have to make it fail if the key's value is null (so that
> it'd say "false" in both of these cases). Either of those options
> seems both weird and useless.
>

yeah. I would expect for json or jsonb, two values, a, b,
a is distinct from b
should give the same answer as
a::text is distinct from b::text

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kyotaro Horiguchi 2022-06-08 01:12:59 Re: SQL state: 42601. Execption handling.
Previous Message Tom Lane 2022-06-07 14:36:52 Re: SQL state: 42601. Execption handling.