]> git.openstreetmap.org Git - nominatim.git/commitdiff
make sure postcode gets recomputed on update
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 2 Jul 2017 14:28:02 +0000 (16:28 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 19 Aug 2017 17:37:05 +0000 (19:37 +0200)
sql/functions.sql

index 573e80e777a79e5c5606b3d8c0154c9a944837ea..1c4fbb64aeec938f52069d7c1f6ee823934466f5 100644 (file)
@@ -1272,6 +1272,7 @@ BEGIN
   -- cheaper but less acurate
   place_centroid := ST_PointOnSurface(NEW.geometry);
   NEW.centroid := null;
+  NEW.postcode := null;
   --DEBUG: RAISE WARNING 'Computing preliminary centroid at %',ST_AsText(place_centroid);
 
   -- recalculate country and partition
@@ -1512,7 +1513,7 @@ BEGIN
       IF NEW.address is not null AND NEW.address ? 'postcode' THEN
           NEW.postcode = NEW.address->'postcode';
       ELSE
-         SELECT postcode FROM placex WHERE place_id = parent_place_id INTO NEW.postcode;
+         SELECT postcode FROM placex WHERE place_id = NEW.parent_place_id INTO NEW.postcode;
       END IF;
       IF NEW.postcode is null THEN
         NEW.postcode := get_nearest_postcode(NEW.country_code, place_centroid);