Project

General

Profile

« Previous | Next » 

Revision 4261

sql.py: pkey(): Use pkey_col constant if this column exists, to allow using a row_num column as the pkey even when it is placed at the end of the table (due to being added after the table was created)

View differences:

lib/sql.py
1074 1074
    return list(col_names(select(db, table, limit=0, order_by=None,
1075 1075
        recover=recover, log_level=4)))
1076 1076

  
1077
pkey_col = 'row_num'
1078

  
1077 1079
def pkey(db, table, recover=None):
1078
    '''Assumed to be first column in table'''
1079
    return table_cols(db, table, recover)[0]
1080
    '''Uses pkey_col, or if not found, the first column in the table.'''
1081
    cols = table_cols(db, table, recover)
1082
    if pkey_col in cols: return pkey_col
1083
    else: return cols[0]
1080 1084

  
1081 1085
not_null_col = 'not_null_col'
1082 1086

  

Also available in: Unified diff