Project

General

Profile

« Previous | Next » 

Revision 12153

lib/sql_io.py: automatic handling of input/output column type mismatches: also do this for identifying columns, which first cause an error in a join in sql.distinct_table() rather than in the main insert (and thus were not handled by the existing error handling). previously, the user would have had to manually cast the input column in postprocess.sql. this involves getting handle_MissingCastException() to update join_cols as well as mapping.

View differences:

trunk/lib/sql_io.py
629 629
            in_col = mapping[out_col]
630 630
            while True:
631 631
                try:
632
                    mapping[out_col] = cast_temp_col(db, type_, in_col,
633
                        errors_table_)
632
                    join_cols[out_col] = mapping[out_col] = cast_temp_col(db,
633
                        type_, in_col, errors_table_)
634 634
                    break # cast successful
635 635
                except sql.InvalidValueException, e:
636 636
                    if not log_exc(e): return False
......
743 743
            # Uniquify and filter input table to avoid (most) duplicate keys
744 744
            # (Additional duplicates may be added concurrently and will be
745 745
            # filtered out separately upon insert.)
746
            insert_in_table = sql.distinct_table(db, insert_in_table,
747
                join_cols.values(), [insert_in_table,
748
                sql_gen.Join(out_table, join_cols, sql_gen.filter_out, e.cond)])
749
            insert_in_tables.append(insert_in_table)
746
            while True:
747
                try:
748
                    insert_in_table = sql.distinct_table(db, insert_in_table,
749
                        join_cols.values(), [insert_in_table,
750
                        sql_gen.Join(out_table, join_cols, sql_gen.filter_out,
751
                        e.cond)])
752
                    insert_in_tables.append(insert_in_table)
753
                    break # insert successful
754
                except sql.MissingCastException, e1: # don't modify outer e
755
                    if not handle_MissingCastException(e1): break
750 756
        except sql.NullValueException, e:
751 757
            if not log_exc(e): break
752 758
            

Also available in: Unified diff