Project

General

Profile

« Previous | Next » 

Revision 5371

sql_gen.py: simplify_expr(): Also simplify "NOT false" to true

View differences:

lib/sql_gen.py
1106 1106
    return '(?:'+expr_re+op_re+value_re+'|'+value_re+op_re+expr_re+')'
1107 1107

  
1108 1108
not_re = r'\bNOT '
1109
not_false_re = not_re+false_re
1109 1110
not_true_re = not_re+true_re
1110 1111
and_false_re = logic_op_re('AND', false_re, atom_re)
1111 1112
and_false_not_true_re = '(?:'+not_true_re+'|'+and_false_re+')'
......
1126 1127
def simplify_expr(expr):
1127 1128
    def simplify_logic_ops(expr):
1128 1129
        total_n = 0
1130
        expr, n = re.subn(not_false_re, true_re, expr)
1131
        total_n += n
1129 1132
        expr, n = re.subn(and_false_not_true_re, false_expr, expr)
1130 1133
        total_n += n
1131 1134
        expr, n = re.subn(or_and_true_re, r'', expr)

Also available in: Unified diff