Indexing: manage the case where no default-language exists

Relates-to commit 6fee784c9f.
This commit is contained in:
James Addison
2026-02-05 20:48:01 +00:00
parent 6fee784c9f
commit fa2a789e27

View File

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