Revision 12150
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/lib/sql_io.py | ||
---|---|---|
616 | 616 |
args = dict(((k.name, v) for k, v in mapping.iteritems())) |
617 | 617 |
return sql_gen.FunctionCall(out_table, **args), args |
618 | 618 |
|
619 |
def handle_MissingCastException(e): |
|
620 |
if not log_exc(e): return False |
|
621 |
|
|
622 |
type_ = e.type |
|
623 |
if e.col == None: out_cols = mapping.keys() |
|
624 |
else: out_cols = [e.col] |
|
625 |
|
|
626 |
for out_col in out_cols: |
|
627 |
log_debug('Casting '+strings.as_tt(strings.repr_no_u(out_col)) |
|
628 |
+' input to '+strings.as_tt(type_)) |
|
629 |
in_col = mapping[out_col] |
|
630 |
while True: |
|
631 |
try: |
|
632 |
mapping[out_col] = cast_temp_col(db, type_, in_col, |
|
633 |
errors_table_) |
|
634 |
break # cast successful |
|
635 |
except sql.InvalidValueException, e: |
|
636 |
if not log_exc(e): return False |
|
637 |
|
|
638 |
ignore(in_col, e.value, e) |
|
639 |
|
|
640 |
return True |
|
641 |
|
|
619 | 642 |
missing_msg = None |
620 | 643 |
|
621 | 644 |
# Do inserts and selects |
... | ... | |
698 | 721 |
main_select, **insert_args) |
699 | 722 |
break # insert successful |
700 | 723 |
except sql.MissingCastException, e: |
701 |
if not log_exc(e): break |
|
702 |
|
|
703 |
type_ = e.type |
|
704 |
if e.col == None: out_cols = mapping.keys() |
|
705 |
else: out_cols = [e.col] |
|
706 |
|
|
707 |
for out_col in out_cols: |
|
708 |
log_debug('Casting '+strings.as_tt(strings.repr_no_u(out_col)) |
|
709 |
+' input to '+strings.as_tt(type_)) |
|
710 |
in_col = mapping[out_col] |
|
711 |
while True: |
|
712 |
try: |
|
713 |
mapping[out_col] = cast_temp_col(db, type_, in_col, |
|
714 |
errors_table_) |
|
715 |
break # cast successful |
|
716 |
except sql.InvalidValueException, e: |
|
717 |
if not log_exc(e): break |
|
718 |
|
|
719 |
ignore(in_col, e.value, e) |
|
724 |
if not handle_MissingCastException(e): break |
|
720 | 725 |
except sql.DuplicateKeyException, e: |
721 | 726 |
if not log_exc(e): break |
722 | 727 |
|
Also available in: Unified diff
lib/sql_io.py: put_table(): main loop MissingCastException handler: factored out into nested function so that it can also be used elsewhere