Project

General

Profile

« Previous | Next » 

Revision 2391

sql.py: Added flatten()

View differences:

sql.py
639 639
        flatten_mapping[orig_col] = col
640 640
    return flatten_mapping
641 641

  
642
def flatten(db, joins, flat_table, limit=None, start=None, **kw_args):
643
    '''For params, see mk_flatten_mapping()
644
    @return See return value of mk_flatten_mapping()
645
    '''
646
    tables = joins[:1]+[v.table for v in joins[1:]]
647
    mapping = mk_flatten_mapping(db, tables, flat_table, **kw_args)
648
    cols = [sql_gen.NamedCol(new.name, old) for old, new in mapping.iteritems()]
649
    run_query_into(db, *mk_select(db, joins, cols, limit=limit, start=start),
650
        into=flat_table)
651
    return mapping
652

  
642 653
def pkey(db, table, recover=None):
643 654
    '''Assumed to be first column in table'''
644 655
    return table_cols(db, table, recover)[0]

Also available in: Unified diff