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