Project

General

Profile

« Previous | Next » 

Revision 4924

csv2db: Fixed bug where tables without a row_num (such as *.src tables) were not properly supported when the CSV contained ragged rows, because the columns were truncated to # column names + 1 but there was no row_num to be the +1. This was solved by moving row_num to the end, so that it does not impact the column count whether it's there or not.

View differences:

bin/csv2db
70 70
        
71 71
        typed_cols = [sql_gen.TypedCol(v, 'text') for v in col_names]
72 72
        if has_row_num:
73
            typed_cols.insert(0, sql_gen.TypedCol('row_num', 'serial',
73
            typed_cols.append(sql_gen.TypedCol('row_num', 'serial',
74 74
                nullable=False))
75 75
        
76 76
        log('Creating table')
......
104 104
                    db.db.cursor().copy_expert(copy_from, line_in)
105 105
                else:
106 106
                    log('Using INSERT')
107
                    cols_ct = len(col_names)+1 # +1 for row_num
107
                    cols_ct = len(col_names)
108 108
                    for row in csvs.make_reader(line_in, dialect):
109 109
                        row = map(strings.to_unicode, row)
110 110
                        row.insert(0, sql.default) # row_num is autogen

Also available in: Unified diff