Project

General

Profile

« Previous | Next » 

Revision 2847

sql.py: add_index(): Added ensure_not_null param to disable the ensure_not_null functionality to force a plain index

View differences:

lib/sql.py
913 913

  
914 914
row_num_col = '_row_num'
915 915

  
916
def add_index(db, exprs, table=None, unique=False):
916
def add_index(db, exprs, table=None, unique=False, ensure_not_null=True):
917 917
    '''Adds an index on column(s) or expression(s) if it doesn't already exist.
918 918
    Currently, only function calls are supported as expressions.
919
    @param ensure_not_null If set, translates NULL values to sentinel values.
920
        This allows indexes to be used for comparisons where NULLs are equal.
919 921
    '''
920 922
    if not lists.is_seq(exprs): exprs = [exprs]
921 923
    
......
928 930
        expr = sql_gen.as_Col(expr, table)
929 931
        
930 932
        # Handle nullable columns
931
        expr = sql_gen.ensure_not_null(db, expr)
933
        if ensure_not_null: expr = sql_gen.ensure_not_null(db, expr)
932 934
        
933 935
        # Extract col
934 936
        if isinstance(expr, sql_gen.FunctionCall):

Also available in: Unified diff