Revision 2855
Added by Aaron Marcuse-Kubitza over 12 years ago
sql_gen.py | ||
---|---|---|
586 | 586 |
|
587 | 587 |
def ensure_not_null(db, col, type_=None): |
588 | 588 |
''' |
589 |
@param col Must have an underlying column.
|
|
589 |
@param col If type_ is not set, must have an underlying column.
|
|
590 | 590 |
@param type_ If set, overrides the underlying column's type. |
591 | 591 |
@return EnsureNotNull|Col |
592 | 592 |
@throws ensure_not_null_excs |
593 | 593 |
''' |
594 |
typed_col = db.col_info(underlying_col(col)) |
|
595 |
if typed_col.nullable: |
|
596 |
col = EnsureNotNull(col, util.coalesce(type_, typed_col.type)) |
|
594 |
nullable = True |
|
595 |
try: typed_col = db.col_info(underlying_col(col)) |
|
596 |
except NoUnderlyingTableException: |
|
597 |
if type_ == None: raise |
|
598 |
else: |
|
599 |
if type_ == None: type_ = typed_col.type |
|
600 |
nullable = typed_col.nullable |
|
601 |
|
|
602 |
if nullable and null_sentinels[type_] != None: |
|
603 |
col = EnsureNotNull(col, type_) |
|
597 | 604 |
return col |
Also available in: Unified diff
sql_gen.py: ensure_not_null(): Support non-column inputs if type_ is set