Revision 2840
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_gen.py | ||
---|---|---|
406 | 406 |
try: |
407 | 407 |
left_non_null = ensure_not_null(db, left_value) |
408 | 408 |
right_non_null = ensure_not_null(db, right_value) |
409 |
except NoUnderlyingTableException: pass
|
|
409 |
except ensure_not_null_excs: pass
|
|
410 | 410 |
else: |
411 | 411 |
if (left_non_null is not left_value |
412 | 412 |
and right_non_null is not right_value): # both were wrapped |
... | ... | |
571 | 571 |
|
572 | 572 |
null_sentinels = {'text': r'\N'} |
573 | 573 |
|
574 |
def ensure_not_null(db, value, ignore_unknown_type=True): |
|
575 |
typed_col = db.col_info(underlying_col(value)) |
|
574 |
ensure_not_null_excs = (NoUnderlyingTableException, KeyError) |
|
575 |
|
|
576 |
def ensure_not_null(db, col): |
|
577 |
''' |
|
578 |
@param col Must have an underlying column. |
|
579 |
@return EnsureNotNull|Col |
|
580 |
@throws ensure_not_null_excs |
|
581 |
''' |
|
582 |
typed_col = db.col_info(underlying_col(col)) |
|
576 | 583 |
if typed_col.nullable: |
577 |
try: null = null_sentinels[typed_col.type] |
|
578 |
except KeyError: |
|
579 |
if not ignore_unknown_type: raise |
|
580 |
else: value = EnsureNotNull(value, null) |
|
581 |
return value |
|
584 |
col = EnsureNotNull(col, null_sentinels[typed_col.type]) |
|
585 |
return col |
Also available in: Unified diff
sql_gen.py: ensure_not_null(): If input column cannot be ensured to be NULL, pass any raised exception through rather than suppressing it and leaving the column in a nullable state