Project

General

Profile

« Previous | Next » 

Revision 2998

sql.py: add_index(): Use new sql.ensure_not_null(), which creates a separate column to store the index expr where possible

View differences:

lib/sql.py
935 935

  
936 936
row_num_col = '_row_num'
937 937

  
938
def add_index(db, exprs, table=None, unique=False, ensure_not_null=True):
938
def add_index(db, exprs, table=None, unique=False, ensure_not_null_=True):
939 939
    '''Adds an index on column(s) or expression(s) if it doesn't already exist.
940 940
    Currently, only function calls are supported as expressions.
941
    @param ensure_not_null If set, translates NULL values to sentinel values.
941
    @param ensure_not_null_ If set, translates NULL values to sentinel values.
942 942
        This allows indexes to be used for comparisons where NULLs are equal.
943 943
    '''
944 944
    exprs = lists.mk_seq(exprs)
......
952 952
        expr = sql_gen.as_Col(expr, table)
953 953
        
954 954
        # Handle nullable columns
955
        if ensure_not_null:
956
            try: expr = sql_gen.ensure_not_null(db, expr)
955
        if ensure_not_null_:
956
            try: expr = ensure_not_null(db, expr)
957 957
            except KeyError: pass # unknown type, so just create plain index
958 958
        
959 959
        # Extract col

Also available in: Unified diff