Project

General

Profile

« Previous | Next » 

Revision 2390

sql.py: mk_flatten_mapping(): preserve Col objects will have tables changed to flat_table to work with flattened table

View differences:

lib/sql.py
619 619
    to names that will be distinct among the given tables.
620 620
    This is meant to be used for several tables that are being joined together.
621 621
    @param flat_table The table for the new columns
622
    @param preserve List of columns not to rename
622
    @param preserve [sql_gen.Col...] Columns not to rename. The tables of the
623
        provided Col objects will be changed to flat_table, so make copies of
624
        them if you want to keep the original tables.
623 625
    @return dict(orig_col=new_col, ...)
624 626
        * orig_col: sql_gen.Col(orig_col_name, orig_table)
625 627
        * new_col: sql_gen.Col(orig_col_name, flat_table)
......
632 634
            col = sql_gen.as_Col(col, table)
633 635
            flatten_mapping[col] = sql_gen.Col(str(col), flat_table)
634 636
    for col in preserve:
635
        flatten_mapping[col] = sql_gen.Col(col.name, flat_table)
637
        orig_col = copy.copy(col)
638
        col.table = flat_table
639
        flatten_mapping[orig_col] = col
636 640
    return flatten_mapping
637 641

  
638 642
def pkey(db, table, recover=None):

Also available in: Unified diff