Project

General

Profile

« Previous | Next » 

Revision 5355

sql.py: Added simplify_recursive()

View differences:

sql.py
1034 1034
def simplify_parens(expr):
1035 1035
    return regexp.sub_nested(r'\((true|false|\([^()]*\))\)', r'\1', expr)
1036 1036

  
1037
def simplify_recursive(sub_func, expr):
1038
    '''
1039
    @param sub_func See regexp.sub_recursive() sub_func param
1040
    '''
1041
    return simplify_parens(regexp.sub_recursive(
1042
        lambda s: sub_func(simplify_parens(s)), expr))
1043

  
1037 1044
def simplify_expr(expr):
1038 1045
    expr = expr.replace('(NULL IS NULL)', 'true')
1039 1046
    expr = expr.replace('(NULL IS NOT NULL)', 'false')

Also available in: Unified diff