Project

General

Profile

« Previous | Next » 

Revision 13076

bin/repl, lib/sql_gen.py Expression transforming: documented that this can also be done in Postgres with expression substitution (wiki.vegpath.org/Postgres_queries#expression-substitution)

View differences:

trunk/lib/sql_gen.py
1164 1164
        # simplify_parens() is also done at end in final iteration
1165 1165

  
1166 1166
def simplify_expr(expr):
1167
    '''
1168
    this can also be done in Postgres with expression substitution
1169
    (wiki.vegpath.org/Postgres_queries#expression-substitution)
1170
    '''
1167 1171
    def simplify_logic_ops(expr):
1168 1172
        total_n = 0
1169 1173
        expr, n = re.subn(not_false_re, true_re, expr)
......
1189 1193
def map_expr(db, expr, mapping, in_cols_found=None):
1190 1194
    '''Replaces output columns with input columns in an expression.
1191 1195
    @param in_cols_found If set, will be filled in with the expr's (input) cols
1196
    
1197
    this can also be done in Postgres with expression substitution
1198
    (wiki.vegpath.org/Postgres_queries#expression-substitution)
1192 1199
    '''
1193 1200
    for out, in_ in mapping.iteritems():
1194 1201
        orig_expr = expr
trunk/bin/repl
57 57
        if in_ != '':
58 58
            is_word = re.match(r'^\w+$', in_)
59 59
            if text or is_word: # match as whole-word text (like SQL identifier)
60
                # this can also be done in Postgres with expression substitution
61
                # (wiki.vegpath.org/Postgres_queries#expression-substitution)
60 62
                in_str_re = re.escape(in_)
61 63
                q = quote_re
62 64
                in_ = '(?<='+q+')'+in_str_re+'(?='+q+')' # require quotes

Also available in: Unified diff