diff --git a/lib-sql/functions/utils.sql b/lib-sql/functions/utils.sql index 3baf8240..30a2aa8a 100644 --- a/lib-sql/functions/utils.sql +++ b/lib-sql/functions/utils.sql @@ -2,7 +2,7 @@ -- -- This file is part of Nominatim. (https://nominatim.org) -- --- Copyright (C) 2025 by the Nominatim developer community. +-- Copyright (C) 2026 by the Nominatim developer community. -- For a full list of authors see the git log. -- Assorted helper functions for the triggers. @@ -46,13 +46,13 @@ DECLARE r INTEGER[]; BEGIN IF array_upper(a, 1) IS NULL THEN - RETURN b; + RETURN COALESCE(b, '{}'::INTEGER[]); END IF; IF array_upper(b, 1) IS NULL THEN - RETURN a; + RETURN COALESCE(a, '{}'::INTEGER[]); END IF; r := a; - FOR i IN 1..array_upper(b, 1) LOOP + FOR i IN 1..array_upper(b, 1) LOOP IF NOT (ARRAY[b[i]] <@ r) THEN r := r || b[i]; END IF;