sql-text-fix
All checks were successful
Deploy on push / deploy (push) Successful in 2m1s

This commit is contained in:
Untone 2024-02-25 16:04:15 +03:00
parent 8b15ef9429
commit a4745df71b

View File

@ -1,7 +1,7 @@
import math import math
import time import time
from functools import wraps from functools import wraps
from sqlalchemy import event, Engine, inspect from sqlalchemy import event, Engine, inspect, text
from typing import Any, Callable, Dict, TypeVar from typing import Any, Callable, Dict, TypeVar
from dogpile.cache import make_region from dogpile.cache import make_region
@ -123,12 +123,11 @@ def create_fts_index(table_name, fts_index_name):
) )
if not author_fts_index_exists: if not author_fts_index_exists:
with local_session() as session: with local_session() as session:
session.execute( q = text("""
"""
CREATE INDEX {index_name} ON {author_table_name} CREATE INDEX {index_name} ON {author_table_name}
USING gin(to_tsvector('russian', COALESCE(name,'') || ' ' || COALESCE(bio,'') || ' ' || COALESCE(about,''))); USING gin(to_tsvector('russian', COALESCE(name,'') || ' ' || COALESCE(bio,'') || ' ' || COALESCE(about,'')));
""".format(index_name=fts_index_name, author_table_name=table_name) """.format(index_name=fts_index_name, author_table_name=table_name))
) session.execute(q)
logger.info('Full text index created successfully.') logger.info('Full text index created successfully.')