generated from teksi/template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #416 from cymed/add-vw_tww_infiltration_installation
Add specialised view for infiltration installation
- Loading branch information
Showing
4 changed files
with
853 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CREATE OR REPLACE FUNCTION tww_app.check_all_nulls(rec record, prefix varchar(2),ignored_postfix text[] default Array['obj_id','identifier']) | ||
RETURNS bool | ||
AS | ||
$BODY$ | ||
DECLARE | ||
rec_jsonb jsonb; | ||
BEGIN | ||
|
||
rec_jsonb := ( | ||
SELECT jsonb_object_agg(key, to_jsonb(rec)->key) | ||
FROM jsonb_object_keys(to_jsonb(rec)) key | ||
WHERE LEFT(key, 2) = prefix | ||
AND NOT(ltrim(key, prefix||'_') =ANY(ignored_postfix)) | ||
); | ||
|
||
-- Check if all remaining values are NULL | ||
RETURN jsonb_strip_nulls(rec_jsonb)::text = '{{}}' OR jsonb_strip_nulls(rec_jsonb)::text IS NULL; | ||
END; | ||
$BODY$ | ||
LANGUAGE plpgsql; |
Oops, something went wrong.