Revision 4997
Added by Aaron Marcuse-Kubitza over 12 years ago
sql.py | ||
---|---|---|
1180 | 1180 |
|
1181 | 1181 |
row_num_col = '_row_num' |
1182 | 1182 |
|
1183 |
row_num_typed_col = sql_gen.TypedCol(row_num_col, 'serial', nullable=False,
|
|
1183 |
row_num_col_def = sql_gen.TypedCol('', 'serial', nullable=False,
|
|
1184 | 1184 |
constraints='PRIMARY KEY') |
1185 | 1185 |
|
1186 |
def add_row_num(db, table): |
|
1187 |
'''Adds a row number column to a table. Its name is in row_num_col. It will |
|
1188 |
be the primary key.''' |
|
1189 |
add_col(db, table, row_num_typed_col, log_level=3) |
|
1186 |
def add_row_num(db, table, name=row_num_col): |
|
1187 |
'''Adds a row number column to a table. Its definition is in |
|
1188 |
row_num_col_def. It will be the primary key.''' |
|
1189 |
col_def = copy.copy(row_num_col_def) |
|
1190 |
col_def.name = name |
|
1191 |
add_col(db, table, col_def, log_level=3) |
|
1190 | 1192 |
|
1191 | 1193 |
#### Indexes |
1192 | 1194 |
|
Also available in: Unified diff
sql.py: add_row_num(): Support custom row number column name