Project

General

Profile

« Previous | Next » 

Revision 3036

sql.py: add_col(): Version column names to avoid collisions. (Previously, callers were required to do this themselves.)

View differences:

sql.py
1117 1117

  
1118 1118
def add_col(db, table, col, **kw_args):
1119 1119
    assert isinstance(col, sql_gen.TypedCol)
1120
    run_query(db, 'ALTER TABLE '+table.to_str(db)+' ADD COLUMN '
1121
        +col.to_str(db), recover=True, cacheable=True, **kw_args)
1120
    
1121
    while True:
1122
        try:
1123
            run_query(db, 'ALTER TABLE '+table.to_str(db)+' ADD COLUMN '
1124
                +col.to_str(db), recover=True, cacheable=True, **kw_args)
1125
            break
1126
        except DuplicateException:
1127
            col.name = next_version(col.name)
1128
            # try again with next version of name
1122 1129

  
1123 1130
row_num_typed_col = sql_gen.TypedCol(row_num_col, 'serial', nullable=False,
1124 1131
    constraints='PRIMARY KEY')

Also available in: Unified diff