diff options
| author | Andrew Dunstan | 2025-03-05 14:50:34 +0000 |
|---|---|---|
| committer | Andrew Dunstan | 2025-03-05 15:04:02 +0000 |
| commit | 4603903d294bbdd644afecf9b5970827db6d1ff5 (patch) | |
| tree | 29212352a8e09f5076b03c752976b416eeba8014 /src/backend/catalog | |
| parent | 5ead85fbc81162ab1594f656b036a22e814f96b3 (diff) | |
Allow json{b}_strip_nulls to remove null array elements
An additional paramater ("strip_in_arrays") is added to these functions.
It defaults to false. If true, then null array elements are removed as
well as null valued object fields. JSON that just consists of a single
null is not affected.
Author: Florents Tselai <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/backend/catalog')
| -rw-r--r-- | src/backend/catalog/system_functions.sql | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql index 86888cd3201..566f308e443 100644 --- a/src/backend/catalog/system_functions.sql +++ b/src/backend/catalog/system_functions.sql @@ -607,6 +607,20 @@ LANGUAGE INTERNAL STRICT STABLE PARALLEL SAFE AS 'jsonb_path_query_first_tz'; +CREATE OR REPLACE FUNCTION + jsonb_strip_nulls(target jsonb, strip_in_arrays boolean DEFAULT false) +RETURNS jsonb +LANGUAGE INTERNAL +STRICT STABLE PARALLEL SAFE +AS 'jsonb_strip_nulls'; + +CREATE OR REPLACE FUNCTION + json_strip_nulls(target json, strip_in_arrays boolean DEFAULT false) +RETURNS json +LANGUAGE INTERNAL +STRICT STABLE PARALLEL SAFE +AS 'json_strip_nulls'; + -- default normalization form is NFC, per SQL standard CREATE OR REPLACE FUNCTION "normalize"(text, text DEFAULT 'NFC') |
