From 6fee784c9fc2bf6ca9428482713347258161e0cc Mon Sep 17 00:00:00 2001 From: James Addison Date: Wed, 28 Jan 2026 00:13:20 +0000 Subject: [PATCH 1/3] Indexing: add default-language placename from linked places --- lib-sql/functions/placex_triggers.sql | 8 ++++++++ test/bdd/features/db/import/linking.feature | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 244fe90c..e1cfe6b0 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -29,6 +29,7 @@ DECLARE location RECORD; result prepare_update_info; extra_names HSTORE; + default_language_key VARCHAR(10); BEGIN IF not p.address ? '_inherited' THEN result.address := p.address; @@ -85,6 +86,13 @@ BEGIN IF location.name is not NULL THEN {% if debug %}RAISE WARNING 'Names original: %, location: %', result.name, location.name;{% endif %} + + -- Merge in a default-language name from the linked place, if none is set + default_language_key := 'name:' || get_country_language_code(location.country_code); + IF NOT location.name ? default_language_key THEN + location.name := location.name || hstore(default_language_key, location.name->'name'); + END IF; + -- Add all names from the place nodes that deviate from the name -- in the relation with the prefix '_place_'. Deviation means that -- either the value is different or a given key is missing completely diff --git a/test/bdd/features/db/import/linking.feature b/test/bdd/features/db/import/linking.feature index dbaac5fc..2629d248 100644 --- a/test/bdd/features/db/import/linking.feature +++ b/test/bdd/features/db/import/linking.feature @@ -297,9 +297,8 @@ Feature: Linking of places | R1 | LabelPlace | - @skip Scenario: Linked places expand default language names - Given the grid + Given the grid with origin CO | 1 | | 2 | | | 9 | | | 4 | | 3 | From fa2a789e270a716be8655ce75ba5ed37fba9e09d Mon Sep 17 00:00:00 2001 From: James Addison Date: Thu, 5 Feb 2026 20:48:01 +0000 Subject: [PATCH 2/3] Indexing: manage the case where no default-language exists Relates-to commit 6fee784c9fc2bf6ca9428482713347258161e0cc. --- lib-sql/functions/placex_triggers.sql | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index e1cfe6b0..319c6b12 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -29,7 +29,7 @@ DECLARE location RECORD; result prepare_update_info; extra_names HSTORE; - default_language_key VARCHAR(10); + default_language VARCHAR(10); BEGIN IF not p.address ? '_inherited' THEN result.address := p.address; @@ -87,10 +87,12 @@ BEGIN IF location.name is not NULL THEN {% if debug %}RAISE WARNING 'Names original: %, location: %', result.name, location.name;{% endif %} - -- Merge in a default-language name from the linked place, if none is set - default_language_key := 'name:' || get_country_language_code(location.country_code); - IF NOT location.name ? default_language_key THEN - location.name := location.name || hstore(default_language_key, location.name->'name'); + default_language := get_country_language_code(location.country_code); + IF default_language is NULL OR location.name ? ('name:' || default_language) THEN + -- No default language, or a name in the local language is already configured; do nothing + ELSE + -- Merge in a default-language name from the linked place + location.name := location.name || hstore('name:' || default_language, location.name->'name'); END IF; -- Add all names from the place nodes that deviate from the name From e62811cf977556efb440a7d92546f8513dfd4bdc Mon Sep 17 00:00:00 2001 From: James Addison Date: Mon, 9 Feb 2026 18:33:02 +0000 Subject: [PATCH 3/3] Indexing: invert boolean logic to factor-out empty `ELSE` clause Relates-to commit fa2a789e270a716be8655ce75ba5ed37fba9e09d. --- lib-sql/functions/placex_triggers.sql | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 319c6b12..9b05a4b3 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -87,11 +87,9 @@ BEGIN IF location.name is not NULL THEN {% if debug %}RAISE WARNING 'Names original: %, location: %', result.name, location.name;{% endif %} + -- Add the linked-place (e.g. city) name as a searchable placename in the default language (if any) default_language := get_country_language_code(location.country_code); - IF default_language is NULL OR location.name ? ('name:' || default_language) THEN - -- No default language, or a name in the local language is already configured; do nothing - ELSE - -- Merge in a default-language name from the linked place + IF default_language is not NULL AND NOT location.name ? ('name:' || default_language) THEN location.name := location.name || hstore('name:' || default_language, location.name->'name'); END IF;