On Jun 11, 2025, at 16:03, Robert Haas <robertmh...@gmail.com> wrote:
> The proposed behavior of the operator you want to add would be > inconsistent with the existing integer subtraction operator, because > the former would remove by value and the latter removes by index. Bear in mind that `-` currently does both. Of the three current variants, the first two delete from an array by value: * jsonb - text: Deletes a key (and its value) from a JSON object, or matching string value(s) from a JSON array. * jsonb - text[] → jsonb: Deletes all matching keys or array elements from the left operand. * jsonb - integer → jsonb: Deletes the array element with specified index (negative integers count from the end). Throws an error if JSON value is not an array. Before I went and looked it up, I was also thinking this could use a different operator. But it’s already a bit overloaded, alas. So I could see the new behavior being: * jsonb - jsonb → jsonb: Deletes the array element with specified value. Throws an error if JSON value is not an array. > Now, none of that means that we couldn't define -(jsonb,jsonb) in the > manner you propose. But that's just a feature idea, not an > inconsistency. Agreed. One might also think of it as a “gap to fill”, but it’s a new behavior. In any event, whether the feature uses `-` is a point we can resolve by consensus, given a patch that implements the feature. Best, David
signature.asc
Description: Message signed with OpenPGP