Project

General

Profile

« Previous | Next » 

Revision 2851

sql_gen.py: ensure_not_null(): Added type_ param to override the underlying column's type

View differences:

lib/sql_gen.py
583 583

  
584 584
ensure_not_null_excs = (NoUnderlyingTableException, KeyError)
585 585

  
586
def ensure_not_null(db, col):
586
def ensure_not_null(db, col, type_=None):
587 587
    '''
588 588
    @param col Must have an underlying column.
589
    @param type_ If set, overrides the underlying column's type.
589 590
    @return EnsureNotNull|Col
590 591
    @throws ensure_not_null_excs
591 592
    '''
592 593
    typed_col = db.col_info(underlying_col(col))
593
    if typed_col.nullable: col = EnsureNotNull(col, typed_col.type)
594
    if typed_col.nullable:
595
        col = EnsureNotNull(col, util.coalesce(type_, typed_col.type))
594 596
    return col

Also available in: Unified diff