mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 01:47:57 +00:00
use psycopg.sql for SQL building in tokenizer
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# This file is part of Nominatim. (https://nominatim.org)
|
# This file is part of Nominatim. (https://nominatim.org)
|
||||||
#
|
#
|
||||||
# Copyright (C) 2025 by the Nominatim developer community.
|
# Copyright (C) 2026 by the Nominatim developer community.
|
||||||
# For a full list of authors see the git log.
|
# For a full list of authors see the git log.
|
||||||
"""
|
"""
|
||||||
Tokenizer implementing normalisation as used before Nominatim 4 but using
|
Tokenizer implementing normalisation as used before Nominatim 4 but using
|
||||||
@@ -294,13 +294,12 @@ class ICUTokenizer(AbstractTokenizer):
|
|||||||
with connect(self.dsn) as conn:
|
with connect(self.dsn) as conn:
|
||||||
drop_tables(conn, 'word')
|
drop_tables(conn, 'word')
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
cur.execute(f"ALTER TABLE {old} RENAME TO word")
|
cur.execute(pysql.SQL("ALTER TABLE {} RENAME TO word")
|
||||||
for idx in ('word_token', 'word_id'):
|
.format(pysql.Identifier(old)))
|
||||||
cur.execute(f"""ALTER INDEX idx_{old}_{idx}
|
for idx in ['word_token', 'word_id'] + [n[0] for n in WORD_TYPES]:
|
||||||
RENAME TO idx_word_{idx}""")
|
cur.execute(pysql.SQL("ALTER INDEX {} RENAME TO {}")
|
||||||
for name, _ in WORD_TYPES:
|
.format(pysql.Identifier(f"idx_{old}_{idx}"),
|
||||||
cur.execute(f"""ALTER INDEX idx_{old}_{name}
|
pysql.Identifier(f"idx_word_{idx}")))
|
||||||
RENAME TO idx_word_{name}""")
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user