Project

General

Profile

« Previous | Next » 

Revision 5340

sql.py: simplify_expr(): Combined replacements of bool_re+' OR ' with the value in either order into one replacement

View differences:

lib/sql.py
1026 1026
def simplify_expr(expr):
1027 1027
    expr = expr.replace('(NULL IS NULL)', 'true')
1028 1028
    expr = expr.replace('(NULL IS NOT NULL)', 'false')
1029
    expr = re.sub(r' OR '+bool_re, r'', expr)
1030
    expr = re.sub(bool_re+r' OR ', r'', expr)
1029
    expr = re.sub(r' OR '+bool_re+'|'+bool_re+r' OR ', r'', expr)
1031 1030
    while True:
1032 1031
        expr, n = re.subn(r'\((\([^()]*\))\)', r'\1', expr)
1033 1032
        if n == 0: break

Also available in: Unified diff