COALESCE to avoid null rows from null fields

This commit is contained in:
Davte 2018-11-21 19:29:23 +01:00
parent accdd373d8
commit ada5458368
2 changed files with 17 additions and 3 deletions

View File

@ -7,7 +7,7 @@ __author__ = "Davide Testa"
__email__ = "davte@libero.it"
__credits__ = "Marco Origlia"
__license__ = "GNU General Public License v3.0"
__version__ = "1.4.0"
__version__ = "1.4.1"
__maintainer__ = "Davide Testa"
__contact__ = "t.me/davte"

View File

@ -1940,10 +1940,24 @@ class Bot(telepot.aio.Bot, Gettable):
"""SELECT telegram_id, MAX(name) name
FROM (
SELECT telegram_id,
COALESCE(
first_name || ' ' || last_name ||
' (' ||username || ')' AS name
' (' || username || ')',
username,
first_name || ' ' || last_name,
last_name,
first_name
) AS name
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}%'
UNION ALL
SELECT telegram_id, name