mirror of
https://github.com/getredash/redash.git
synced 2026-05-09 12:01:08 -04:00
Fix: support unicode in users search
This commit is contained in:
@@ -506,7 +506,7 @@ class User(TimestampMixin, db.Model, BelongsToOrgMixin, UserMixin, PermissionsCh
|
||||
|
||||
@classmethod
|
||||
def search(cls, base_query, term):
|
||||
term = '%{}%'.format(term)
|
||||
term = u'%{}%'.format(term)
|
||||
search_filter = or_(cls.name.ilike(term), cls.email.like(term))
|
||||
|
||||
return base_query.filter(search_filter)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from tests import BaseTestCase
|
||||
|
||||
from redash.models import User, db
|
||||
@@ -49,3 +50,10 @@ class TestUserGetByEmailAndOrg(BaseTestCase):
|
||||
|
||||
found_user = User.get_by_email_and_org("TEST@example.com", user.org)
|
||||
self.assertEqual(user, found_user)
|
||||
|
||||
|
||||
class TestUserSearch(BaseTestCase):
|
||||
def test_non_unicode_search_string(self):
|
||||
user = self.factory.create_user(name=u'אריק')
|
||||
|
||||
assert user in User.search(User.all(user.org), term=u'א')
|
||||
|
||||
Reference in New Issue
Block a user