Project

General

Profile

« Previous | Next » 

Revision 2823

sql.py: add_index(): Handle nullable columns by using sql_gen.ensure_not_null() to automatically add a coalesce() wrapper where needed

View differences:

lib/sql.py
925 925
    cols = []
926 926
    for i, expr in enumerate(old_exprs):
927 927
        expr = copy.deepcopy(expr) # don't modify input!
928
        expr = sql_gen.as_Col(expr)
928
        expr = sql_gen.as_Col(expr, table)
929 929
        
930
        # Handle nullable columns
931
        expr = sql_gen.ensure_not_null(db, expr)
932
        
930 933
        # Extract col
931 934
        if isinstance(expr, sql_gen.FunctionCall):
932 935
            col = expr.args[0]
933 936
            expr = sql_gen.Expr(expr)
934 937
        else: col = expr
938
        assert isinstance(col, sql_gen.Col)
935 939
        
936 940
        # Extract table
937 941
        if table == None:

Also available in: Unified diff