Changeset - 0dbf225439ed
[Not reviewed]
default
0 1 0
FUJIWARA Katsunori - 9 years ago 2017-03-25 09:35:46
foozy@lares.dti.ne.jp
admin: apply LOWER() on journal filtering term for suffix/infix matching

Before this revision, LOWER() (via func.lower() of sqlalchemy) isn't
applied on journal filtering term for suffix and infix matching, even
though it is applied for prefix or immediate value matching.

This causes unexpected result with DBMS, which compares strings case-
sensitively by default.

This revision applies LOWER() on journal filtering term for
suffix/infix matching, to filter journal case-insensitively.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/admin/admin.py
Show inline comments
 
@@ -64,18 +64,18 @@ def _journal_filter(user_log, search_ter
 
        log.debug('Filtering using parsed query %r', qry)
 

	
 
    def wildcard_handler(col, wc_term):
 
        if wc_term.startswith('*') and not wc_term.endswith('*'):
 
            #postfix == endswith
 
            wc_term = remove_prefix(wc_term, prefix='*')
 
            return func.lower(col).endswith(wc_term)
 
            return func.lower(col).endswith(func.lower(wc_term))
 
        elif wc_term.startswith('*') and wc_term.endswith('*'):
 
            #wildcard == ilike
 
            wc_term = remove_prefix(wc_term, prefix='*')
 
            wc_term = remove_suffix(wc_term, suffix='*')
 
            return func.lower(col).contains(wc_term)
 
            return func.lower(col).contains(func.lower(wc_term))
 

	
 
    def get_filterion(field, val, term):
 

	
 
        if field == 'repository':
 
            field = getattr(UserLog, 'repository_name')
 
        elif field == 'ip':
0 comments (0 inline, 0 general)