Project

General

Profile

« Previous | Next » 

Revision 5363

sql.py: Added atom_re and use it in simplify_parens()

View differences:

lib/sql.py
1024 1024
true_re = r'true'
1025 1025
false_re = r'false'
1026 1026
bool_re = r'(?:'+true_re+r'|'+false_re+r')'
1027
atom_re = r'(?:'+bool_re+r'|\([^()]*\)'+r')'
1027 1028

  
1028 1029
def logic_op_re(op, value_re, expr_re=''):
1029 1030
    op_re = ' '+op+' '
......
1032 1033
or_re = logic_op_re('OR', bool_re)
1033 1034

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

  
1037 1038
def simplify_recursive(sub_func, expr):
1038 1039
    '''

Also available in: Unified diff