Mercurial > kallithea
changeset 7132:3971715302b1
home: make sure users and group autocomplete is case insensitive
Both SQLite and MySQL have a case-insensitive LIKE operator by default, but
PostgreSQL does not. As a result, a query for 'john' does not match the user
'John Doe'.
As case-insensitivity is most user-friendly in the context of autocompletion
of users and groups, switch to the ilike() method of SQLAlchemy rather than
like().
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Fri, 02 Feb 2018 15:52:53 +0100 |
parents | 33bd2aa757dd |
children | 5ab31ff3011f |
files | kallithea/controllers/home.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/home.py Tue Jan 30 13:57:26 2018 +0100 +++ b/kallithea/controllers/home.py Fri Feb 02 15:52:53 2018 +0100 @@ -173,9 +173,9 @@ .filter(User.is_default_user == False) \ .filter(User.active == True) \ .filter(or_( - User.username.like("%%"+query+"%%"), - User.name.like("%%"+query+"%%"), - User.lastname.like("%%"+query+"%%"), + User.username.ilike("%%"+query+"%%"), + User.name.ilike("%%"+query+"%%"), + User.lastname.ilike("%%"+query+"%%"), )) \ .order_by(User.username) \ .limit(500) \ @@ -198,7 +198,7 @@ grp_list = [grp] elif query: grp_list = UserGroup.query() \ - .filter(UserGroup.users_group_name.like("%%"+query+"%%")) \ + .filter(UserGroup.users_group_name.ilike("%%"+query+"%%")) \ .filter(UserGroup.users_group_active == True) \ .order_by(UserGroup.users_group_name) \ .limit(500) \