Project

General

Profile

« Previous | Next » 

Revision 5370

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

View differences:

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

  
1108
not_re = r'\bNOT '
1109
not_true_re = not_re+true_re
1108 1110
and_false_re = logic_op_re('AND', false_re, atom_re)
1111
and_false_not_true_re = '(?:'+not_true_re+'|'+and_false_re+')'
1109 1112
and_true_re = logic_op_re('AND', true_re)
1110 1113
or_re = logic_op_re('OR', bool_re)
1111 1114
or_and_true_re = '(?:'+and_true_re+'|'+or_re+')'
......
1123 1126
def simplify_expr(expr):
1124 1127
    def simplify_logic_ops(expr):
1125 1128
        total_n = 0
1126
        expr, n = re.subn(and_false_re, false_expr, expr)
1129
        expr, n = re.subn(and_false_not_true_re, false_expr, expr)
1127 1130
        total_n += n
1128 1131
        expr, n = re.subn(or_and_true_re, r'', expr)
1129 1132
        total_n += n

Also available in: Unified diff