X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/625b1cd17dd486fef9e6d020b1a2079a976808ed..5f036d9923ee80b160648f43cd5e64d1b5f90a49:/sql/functions.sql

diff --git a/sql/functions.sql b/sql/functions.sql
index b61f52b2..5c4e9f2d 100644
--- a/sql/functions.sql
+++ b/sql/functions.sql
@@ -920,7 +920,7 @@ BEGIN
       IF NEW.name ? 'name' AND NOT NEW.name ? ('name:'||default_language) THEN
         NEW.name := NEW.name || (('name:'||default_language) => (NEW.name -> 'name'));
       ELSEIF NEW.name ? ('name:'||default_language) AND NOT NEW.name ? 'name' THEN
-        NEW.name := NEW.name || ('name' => (NEW.name -> 'name:'||default_language));
+        NEW.name := NEW.name || ('name' => (NEW.name -> ('name:'||default_language)));
       END IF;
     END IF;
   END IF;
@@ -942,6 +942,11 @@ BEGIN
     -- By doing in postgres we have the country available to us - currently only used for postcode
     IF NEW.class in ('place','boundary') AND NEW.type in ('postcode','postal_code') THEN
 
+        IF NEW.postcode IS NULL THEN
+            -- most likely just a part of a multipolygon postcode boundary, throw it away
+            RETURN NULL;
+        END IF;
+
         NEW.name := 'ref'=>NEW.postcode;
 
         IF NEW.country_code = 'gb' THEN
@@ -1271,7 +1276,7 @@ BEGIN
         IF NEW.name ? 'name' AND NOT NEW.name ? ('name:'||default_language) THEN
           NEW.name := NEW.name || (('name:'||default_language) => (NEW.name -> 'name'));
         ELSEIF NEW.name ? ('name:'||default_language) AND NOT NEW.name ? 'name' THEN
-          NEW.name := NEW.name || ('name' => (NEW.name -> 'name:'||default_language));
+          NEW.name := NEW.name || ('name' => (NEW.name -> ('name:'||default_language)));
         END IF;
       END IF;
     END IF;
