Revision 2389
Added by Aaron Marcuse-Kubitza over 12 years ago
sql.py | ||
---|---|---|
614 | 614 |
return list(col_names(select(db, table, limit=0, order_by=None, |
615 | 615 |
recover=recover))) |
616 | 616 |
|
617 |
def mk_flatten_mapping(db, tables, flat_table): |
|
617 |
def mk_flatten_mapping(db, tables, flat_table, preserve=[]):
|
|
618 | 618 |
'''Creates a mapping from original column names (which may have collisions) |
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 | 623 |
@return dict(orig_col=new_col, ...) |
623 | 624 |
* orig_col: sql_gen.Col(orig_col_name, orig_table) |
624 | 625 |
* new_col: sql_gen.Col(orig_col_name, flat_table) |
... | ... | |
630 | 631 |
for col in table_cols(db, table): |
631 | 632 |
col = sql_gen.as_Col(col, table) |
632 | 633 |
flatten_mapping[col] = sql_gen.Col(str(col), flat_table) |
634 |
for col in preserve: |
|
635 |
flatten_mapping[col] = sql_gen.Col(col.name, flat_table) |
|
633 | 636 |
return flatten_mapping |
634 | 637 |
|
635 | 638 |
def pkey(db, table, recover=None): |
Also available in: Unified diff
sql.py: mk_flatten_mapping(): Added preserve param for list of columns not to rename