Project

General

Profile

« Previous | Next » 

Revision 5337

sql.py: Renamed table_cols() to table_col_names() for clarity, because it does not return sql_gen.Col objects

View differences:

lib/sql.py
1086 1086
    return value(run_query(db, mk_select(db, table, [sql_gen.row_count],
1087 1087
        order_by=None), recover=recover, log_level=3))
1088 1088

  
1089
def table_cols(db, table, recover=None):
1089
def table_col_names(db, table, recover=None):
1090 1090
    return list(col_names(select(db, table, limit=0, order_by=None,
1091 1091
        recover=recover, log_level=4)))
1092 1092

  
......
1110 1110
    
1111 1111
    try: return value(select(db, tables, cols, conds, order_by=order_by,
1112 1112
        limit=1, log_level=4))
1113
    except StopIteration: return table_cols(db, table, recover)[0]
1113
    except StopIteration: return table_col_names(db, table, recover)[0]
1114 1114

  
1115 1115
def pkey_col_(db, table, *args, **kw_args):
1116 1116
    return sql_gen.Col(pkey(db, table, *args, **kw_args), table)
......
1119 1119

  
1120 1120
def table_not_null_col(db, table, recover=None):
1121 1121
    '''Name assumed to be the value of not_null_col. If not found, uses pkey.'''
1122
    if not_null_col in table_cols(db, table, recover): return not_null_col
1122
    if not_null_col in table_col_names(db, table, recover): return not_null_col
1123 1123
    else: return pkey(db, table, recover)
1124 1124

  
1125 1125
def constraint_cond(db, constraint):
......
1288 1288
        index should be added on the first column.
1289 1289
        * If already_indexed, the pkey is assumed to have already been added
1290 1290
    '''
1291
    cols = table_cols(db, table)
1291
    cols = table_col_names(db, table)
1292 1292
    if has_pkey:
1293 1293
        if has_pkey is not already_indexed: add_pkey(db, table)
1294 1294
        cols = cols[1:]
lib/sql_io.py
25 25
def cleanup_table(db, table):
26 26
    table = sql_gen.as_Table(table)
27 27
    cols = [sql_gen.as_Col(strings.ustr(c), table)
28
        for c in sql.table_cols(db, table)]
28
        for c in sql.table_col_names(db, table)]
29 29
    cols = filter(lambda c: sql_gen.is_text_col(db, c), cols)
30 30
    try: cols.remove(sql.pkey_col_(db, table))
31 31
    except ValueError: pass
......
222 222
##### Import
223 223

  
224 224
def append_csv(db, table, stream_info, stream, use_copy_from=True):
225
    assert sql.table_cols(db, table) == stream_info.header
225
    assert sql.table_col_names(db, table) == stream_info.header
226 226
    
227 227
    def log(msg, level=1): db.log_debug(msg, level)
228 228
    
......
469 469
        else:
470 470
            out_table_cols = sql_gen.ColDict(db, out_table)
471 471
            out_table_cols.update(util.dict_subset_right_join({},
472
                sql.table_cols(db, out_table)))
472
                sql.table_col_names(db, out_table)))
473 473
            
474 474
            in_cols = []
475 475
            cond = sql.map_expr(db, cond, mapping, in_cols)

Also available in: Unified diff