From 6649cef2cfb3676f2e221ee334e9426e7ed82b51 Mon Sep 17 00:00:00 2001 From: Itz-Agasta Date: Wed, 12 Aug 2026 13:40:06 +0530 Subject: [PATCH] Parse the array literal returned for the categories column The driver does not know ltree[] and hands out the array literal as a string. The SQLite export then joined the characters of that string instead of the categories. --- src/nominatim_api/sql/sqlalchemy_types/ltree.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nominatim_api/sql/sqlalchemy_types/ltree.py b/src/nominatim_api/sql/sqlalchemy_types/ltree.py index 6be7a5aa..b53d8914 100644 --- a/src/nominatim_api/sql/sqlalchemy_types/ltree.py +++ b/src/nominatim_api/sql/sqlalchemy_types/ltree.py @@ -36,7 +36,14 @@ class CategoryArray(sa.types.UserDefinedType): # type: ignore[type-arg] def result_processor(self, dialect: 'sa.Dialect', coltype: object) -> Optional[Callable[[Any], Any]]: if dialect.name == 'postgresql': - return None + def process_pg(value: Any) -> Optional[list[str]]: + # ltree[] is unknown to the driver, so it hands out the + # literal text representation of the array. + if value is None or isinstance(value, list): + return value + value = value.strip('{}') + return value.split(',') if value else [] + return process_pg def process(value: Any) -> Optional[list[str]]: return value.split(',') if value else None -- 2.47.3