From: Sarah Hoffmann Date: Mon, 12 Feb 2018 20:19:27 +0000 (+0100) Subject: reimport boundaries from scratch when type is changed X-Git-Tag: v3.2.0~126 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/c3483747ebd10bbe0c4d4914be189050c7178db2 reimport boundaries from scratch when type is changed Fixes #895. --- diff --git a/sql/functions.sql b/sql/functions.sql index 58d3fc7d..1829c63d 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -2200,7 +2200,9 @@ BEGIN -- To paraphrase, if there isn't an existing item, OR if the admin level has changed IF existingplacex.osm_type IS NULL OR - (coalesce(existingplacex.admin_level, 15) != coalesce(NEW.admin_level, 15) AND existingplacex.class = 'boundary' AND existingplacex.type = 'administrative') + (existingplacex.class = 'boundary' AND + ((coalesce(existingplacex.admin_level, 15) != coalesce(NEW.admin_level, 15) AND existingplacex.type = 'administrative') OR + (existingplacex.type != NEW.type))) THEN IF existingplacex.osm_type IS NOT NULL THEN diff --git a/test/bdd/db/update/simple.feature b/test/bdd/db/update/simple.feature index ecbb1244..d48e97fa 100644 --- a/test/bdd/db/update/simple.feature +++ b/test/bdd/db/update/simple.feature @@ -85,3 +85,22 @@ Feature: Update of simple objects | osm | class | type | name | admin | geometry | | W1 | boundary | administrative | Haha | 5 | 1, 2, 4, 3 | Then placex has no entry for W1 + + #895 + Scenario: update rank when boundary is downgraded from admin to historic + Given the grid + | 1 | 2 | + | 3 | 4 | + And the places + | osm | class | type | name | admin | geometry | + | W1 | boundary | administrative | Haha | 5 | (1, 2, 4, 3, 1) | + When importing + Then placex contains + | object | rank_address | + | W1 | 10 | + When updating places + | osm | class | type | name | admin | geometry | + | W1 | boundary | historic | Haha | 5 | (1, 2, 4, 3, 1) | + Then placex contains + | object | rank_address | + | W1 | 0 |