Revision 2415
Added by Aaron Marcuse-Kubitza about 12 years ago
sql.py | ||
---|---|---|
634 | 634 |
|
635 | 635 |
def mk_flatten_mapping(db, into, cols, preserve=[], as_items=False): |
636 | 636 |
'''Creates a mapping from original column names (which may have collisions) |
637 |
to names that will be distinct among the given tables.
|
|
637 |
to names that will be distinct among the columns' tables.
|
|
638 | 638 |
This is meant to be used for several tables that are being joined together. |
639 |
@param into The table for the new columns |
|
639 |
@param cols The columns to combine. Duplicates will be removed. |
|
640 |
@param into The table for the new columns. |
|
640 | 641 |
@param preserve [sql_gen.Col...] Columns not to rename. Note that these |
641 | 642 |
columns will be included in the mapping even if they are not in cols. |
642 | 643 |
The tables of the provided Col objects will be changed to into, so make |
... | ... | |
648 | 649 |
* All mappings use the into table so its name can easily be |
649 | 650 |
changed for all columns at once |
650 | 651 |
''' |
652 |
cols = lists.uniqify(cols) |
|
653 |
|
|
651 | 654 |
items = [] |
652 | 655 |
for col in preserve: |
653 | 656 |
orig_col = copy.copy(col) |
Also available in: Unified diff
lists.py: Added uniqify()