From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: mark.drake@golden-hind.com <mark.drake@golden-hind.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #18809: Inconsistent JSON behavoir
Date: Thu, 13 Feb 2025 01:06:38 -0500
Message-ID: <3530348.1739426798@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZwevnpm4QfGxU8HekDAvdjg72_z1bdiyyKaMgiXLB3BA@mail.gmail.com>
References: <18809-601694c9be8a4026@postgresql.org>
<CAKFQuwZwevnpm4QfGxU8HekDAvdjg72_z1bdiyyKaMgiXLB3BA@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wednesday, February 12, 2025, PG Bug reporting form <
> noreply@postgresql.org> wrote:
>> broadway=# select jsonb('[2,3,1]') - to_jsonb(1);
>> ERROR: operator does not exist: jsonb - jsonb
>> LINE 1: select jsonb('[2,3,1]') - to_jsonb(1);
> This would be a feature request, not a bug report.
Indeed. We have these cases today:
postgres=# \do -
List of operators
Schema | Name | Left arg type | Right arg type | Result type | Description
------------+------+-----------------------------+-----------------------------+-----------------------------+-------------------------------------
...
pg_catalog | - | jsonb | integer | jsonb | delete array element
pg_catalog | - | jsonb | text | jsonb | delete object field
pg_catalog | - | jsonb | text[] | jsonb | delete object fields
...
These are already less than consistent, for example this is allowed:
postgres=# select jsonb('[2,3,1]') - 'foo'::text;
?column?
-----------
[2, 3, 1]
(1 row)
but this not so much:
postgres=# select jsonb('{"a": 1, "b": 2}') - 1;
ERROR: cannot delete from object using integer index
To invent jsonb - jsonb, you'd need to define its behavior for
every possible JSON structure on each side. I foresee plenty of
bikeshedding.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, mark.drake@golden-hind.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18809: Inconsistent JSON behavoir
In-Reply-To: <3530348.1739426798@sss.pgh.pa.us>
* 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