-- 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
| 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 |