Revision 4488
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_gen.py | ||
---|---|---|
1041 | 1041 |
def ensure_not_null(db, col, type_=None): |
1042 | 1042 |
''' |
1043 | 1043 |
@param col If type_ is not set, must have an underlying column. |
1044 |
@param type_ If set, overrides the underlying column's type. |
|
1044 |
@param type_ If set, overrides the underlying column's type and casts the |
|
1045 |
column to it if needed. |
|
1045 | 1046 |
@return EnsureNotNull|Col |
1046 | 1047 |
@throws ensure_not_null_excs |
1047 | 1048 |
''' |
... | ... | |
1053 | 1054 |
elif type_ == None: raise |
1054 | 1055 |
else: |
1055 | 1056 |
if type_ == None: type_ = typed_col.type |
1057 |
elif type_ != typed_col.type: col = Cast(type_, col) |
|
1056 | 1058 |
nullable = typed_col.nullable |
1057 | 1059 |
|
1058 | 1060 |
if nullable: |
Also available in: Unified diff
sql_gen.py: ensure_not_null(): If type_ is set, cast the column to it if needed