mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 06:51:12 -05:00
- Implement helper filter_jsonb_array_nulls and apply it in analyze_data_completeness to replace jsonb - 'null' usage - Add search_path public in helper function for security - Ensure useDataCompleteness runs only on admin pages by enabling query conditionally
14 lines
341 B
PL/PgSQL
14 lines
341 B
PL/PgSQL
-- Fix search_path security issue for filter_jsonb_array_nulls function
|
|
CREATE OR REPLACE FUNCTION filter_jsonb_array_nulls(arr JSONB)
|
|
RETURNS JSONB
|
|
LANGUAGE SQL
|
|
IMMUTABLE
|
|
SET search_path = public
|
|
AS $$
|
|
SELECT COALESCE(
|
|
jsonb_agg(element),
|
|
'[]'::jsonb
|
|
)
|
|
FROM jsonb_array_elements_text(arr) element
|
|
WHERE element != 'null'
|
|
$$; |