jsonb_delete
jsonb_delete · hstore-style delete function and operator for jsonb
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100594 | jsonb_delete | jsonb_delete | 1.0 | FUNC | Unknown | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
jsonb_delete 1.0 adds jsonb_delete(jsonb, jsonb) and the binary jsonb - jsonb operator. For objects, it removes a top-level entry only when both its key and complete value match the right-hand object. For arrays, it removes top-level elements equal to elements in the right-hand array.
Object Difference
Changing only the right-hand value is not enough to delete a key. This differs from PostgreSQL’s core key-deletion forms such as jsonb - text.
Array Difference
Boundaries
Deletion is not recursive. A nested object or array is removed only when the entire top-level value is equal; matching descendants inside a retained value are not edited. The function is STRICT, so a SQL NULL argument produces SQL NULL, while JSON null participates in JSON equality normally.
This API was created for PostgreSQL 9.4/9.5 before most core JSONB modification operators existed and uses PostgreSQL’s internal JSONB C structures. Build and regression-test it on each target major. Because it introduces the jsonb - jsonb overload, audit application operator resolution when other JSONB extensions define related overloads.