|
@@ -1940,10 +1940,24 @@ class Bot(telepot.aio.Bot, Gettable):
|
|
"""SELECT telegram_id, MAX(name) name
|
|
"""SELECT telegram_id, MAX(name) name
|
|
FROM (
|
|
FROM (
|
|
SELECT telegram_id,
|
|
SELECT telegram_id,
|
|
|
|
+ COALESCE(
|
|
first_name || ' ' || last_name ||
|
|
first_name || ' ' || last_name ||
|
|
- ' (' ||username || ')' AS name
|
|
|
|
|
|
+ ' (' || username || ')',
|
|
|
|
+ username,
|
|
|
|
+ first_name || ' ' || last_name,
|
|
|
|
+ last_name,
|
|
|
|
+ first_name
|
|
|
|
+ ) AS name
|
|
FROM users
|
|
FROM users
|
|
- WHERE first_name || last_name || username
|
|
|
|
|
|
+ WHERE COALESCE(
|
|
|
|
+ first_name || last_name || username,
|
|
|
|
+ first_name || username,
|
|
|
|
+ last_name || username,
|
|
|
|
+ first_name || last_name,
|
|
|
|
+ username,
|
|
|
|
+ last_name,
|
|
|
|
+ first_name
|
|
|
|
+ )
|
|
LIKE '%{u}%'
|
|
LIKE '%{u}%'
|
|
UNION ALL
|
|
UNION ALL
|
|
SELECT telegram_id, name
|
|
SELECT telegram_id, name
|