Project

General

Profile

« Previous | Next » 

Revision 5362

sql.py: Added or_re and use it in simplify_expr()

View differences:

lib/sql.py
1029 1029
    op_re = ' '+op+' '
1030 1030
    return '(?:'+expr_re+op_re+value_re+'|'+value_re+op_re+expr_re+')'
1031 1031

  
1032
or_re = logic_op_re('OR', bool_re)
1033

  
1032 1034
def simplify_parens(expr):
1033 1035
    return regexp.sub_nested(r'\(('+bool_re+r'|\([^()]*\))\)', r'\1', expr)
1034 1036

  
......
1042 1044
def simplify_expr(expr):
1043 1045
    expr = expr.replace('(NULL IS NULL)', 'true')
1044 1046
    expr = expr.replace('(NULL IS NOT NULL)', 'false')
1045
    expr = simplify_recursive(
1046
        lambda s: re.subn(logic_op_re('OR', bool_re), r'', s), expr)
1047
    expr = simplify_recursive(lambda s: re.subn(or_re, r'', s), expr)
1047 1048
    return expr
1048 1049

  
1049 1050
name_re = r'(?:\w+|(?:"[^"]*")+)'

Also available in: Unified diff