From 70b9140f139b8f450ca2347dbd12e2d26853bfe1 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 12 Feb 2026 10:56:52 +0100 Subject: [PATCH] pass reverse-only as a separate parameter ... instead of hacking the internal structures of SQLPreprocessor --- lib-sql/tables/search_name.sql | 2 +- src/nominatim_db/tools/database_import.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib-sql/tables/search_name.sql b/lib-sql/tables/search_name.sql index a5b802fa..5ea3d5f8 100644 --- a/lib-sql/tables/search_name.sql +++ b/lib-sql/tables/search_name.sql @@ -7,7 +7,7 @@ DROP TABLE IF EXISTS search_name; -{% if not db.reverse_only %} +{% if not create_reverse_only %} CREATE TABLE search_name ( place_id BIGINT NOT NULL, diff --git a/src/nominatim_db/tools/database_import.py b/src/nominatim_db/tools/database_import.py index 18a7c321..9af74bf6 100644 --- a/src/nominatim_db/tools/database_import.py +++ b/src/nominatim_db/tools/database_import.py @@ -152,12 +152,11 @@ def create_tables(conn: Connection, config: Configuration, reverse_only: bool = When `reverse_only` is True, then the main table for searching will be skipped and only reverse search is possible. """ - sql = SQLPreprocessor(conn, config) - sql.env.globals['db']['reverse_only'] = reverse_only + SQLPreprocessor(conn, config).run_sql_file(conn, 'tables.sql', + create_reverse_only=reverse_only) - sql.run_sql_file(conn, 'tables.sql') - - sql.run_sql_file(conn, 'grants.sql') + # reinitiate the preprocessor to get all the newly created tables + SQLPreprocessor(conn, config).run_sql_file(conn, 'grants.sql') def create_table_triggers(conn: Connection, config: Configuration) -> None: