From 0d184ea85959e548dd9be3535d6048123aaa2fc6 Mon Sep 17 00:00:00 2001 From: Fabio De Simone Date: Tue, 29 Jan 2019 14:48:53 +0100 Subject: [PATCH] fixed warning in /cerca --- telegrambot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telegrambot.py b/telegrambot.py index 91c7b0ae..217e4441 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -4,6 +4,7 @@ import typing import db import errors import stagismo +from sqlalchemy.sql import text # python-telegram-bot has a different name # noinspection PyPackageRequirements from telegram import Bot, Update, InlineKeyboardMarkup, InlineKeyboardButton @@ -305,7 +306,7 @@ def cmd_cerca(bot: Bot, update: Update): bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX)) return queryText = queryText.replace('%', '\\%').replace('_', '\\_') - entries = session.query(db.Diario).filter(f"text ~* '(?:[^\w\d]+{queryText}[^\w\d]+|^{queryText}[^\w\d]+|^{queryText}$|[^\w\d]+{queryText}$)'").order_by(db.Diario.id).all() + entries = session.query(db.Diario).filter(text(f"text ~* '(?:[^\w\d]+{queryText}[^\w\d]+|^{queryText}[^\w\d]+|^{queryText}$|[^\w\d]+{queryText}$)'")).order_by(db.Diario.id).all() msg = f"Risultati della ricerca di {queryText}:\n" for entry in entries[:5]: msg += f'#{entry.id} di {entry.author or "Anonimo"}\n{entry.text}\n\n'