Project

General

Profile

« Previous | Next » 

Revision 2822

sql_gen.py: Added ensure_not_null()

View differences:

lib/sql_gen.py
544 544
        return str_
545 545
    
546 546
    def to_Col(self): return Col(self.name)
547

  
548
null_sentinels = {'text': r'\N'}
549

  
550
def ensure_not_null(db, value):
551
    if is_table_col(value):
552
        typed_col = db.col_info(value)
553
        if typed_col.nullable:
554
            try: null = null_sentinels[typed_col.type]
555
            except KeyError: pass
556
            else: return EnsureNotNull(value, null)
557
    return value

Also available in: Unified diff