Revision 5365
Added by Aaron Marcuse-Kubitza about 12 years ago
sql.py | ||
---|---|---|
1031 | 1031 |
return '(?:'+expr_re+op_re+value_re+'|'+value_re+op_re+expr_re+')' |
1032 | 1032 |
|
1033 | 1033 |
and_false_re = logic_op_re('AND', false_re, atom_re) |
1034 |
and_true_re = logic_op_re('AND', true_re) |
|
1034 | 1035 |
or_re = logic_op_re('OR', bool_re) |
1036 |
or_and_true_re = '(?:'+and_true_re+'|'+or_re+')' |
|
1035 | 1037 |
|
1036 | 1038 |
def simplify_parens(expr): |
1037 | 1039 |
return regexp.sub_nested(r'\(('+atom_re+')\)', r'\1', expr) |
... | ... | |
1048 | 1050 |
total_n = 0 |
1049 | 1051 |
expr, n = re.subn(and_false_re, 'false', expr) |
1050 | 1052 |
total_n += n |
1051 |
expr, n = re.subn(or_re, r'', expr) |
|
1053 |
expr, n = re.subn(or_and_true_re, r'', expr)
|
|
1052 | 1054 |
total_n += n |
1053 | 1055 |
return expr, total_n |
1054 | 1056 |
|
Also available in: Unified diff
sql.py: simplify_expr(): Also simplify "AND true" expressions