Files
thrilltrack-explorer/supabase/migrations/20251112014542_0ab65adf-d76e-4a44-9695-35402dd46bcb.sql
gpt-engineer-app[bot] 842861af8c Fix JSONB filter and admin guard
- 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
2025-11-12 01:45:56 +00:00

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'
$$;