Revision 2158
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
675 | 675 |
@return (table, col) Where the pkeys (from INSERT RETURNING) are made |
676 | 676 |
available |
677 | 677 |
''' |
678 |
temp_prefix = '_'.join(map(clean_name,
|
|
678 |
temp_suffix = '_'.join(map(clean_name,
|
|
679 | 679 |
[out_table] + list(iters.flatten_n(mapping.items(), depth=3)))) |
680 |
pkeys_ref = [temp_prefix+'_pkeys'] |
|
680 |
# suffix, not prefix, so main name won't be removed if name is truncated |
|
681 |
pkeys_ref = ['pkeys_'+temp_suffix] |
|
681 | 682 |
|
682 | 683 |
# Join together input tables |
683 | 684 |
in_tables = in_tables[:] # don't modify input! |
... | ... | |
692 | 693 |
return mk_select(db, in_joins, cols, limit=limit, start=start, |
693 | 694 |
table_is_esc=table_is_esc) |
694 | 695 |
|
695 |
out_pkeys_ref = [temp_prefix+'_out_pkeys']
|
|
696 |
out_pkeys_ref = ['out_pkeys_'+temp_suffix]
|
|
696 | 697 |
def insert_(): |
697 | 698 |
'''Inserts and capture output pkeys.''' |
698 | 699 |
cur = insert_select(db, out_table, mapping.keys(), |
... | ... | |
703 | 704 |
add_row_num(db, out_pkeys_ref[0]) # for joining it with input pkeys |
704 | 705 |
|
705 | 706 |
# Get input pkeys corresponding to rows in insert |
706 |
in_pkeys_ref = [temp_prefix+'_in_pkeys']
|
|
707 |
in_pkeys_ref = ['in_pkeys_'+temp_suffix]
|
|
707 | 708 |
run_query_into(db, *mk_select_([in_pkey]), into_ref=in_pkeys_ref) |
708 | 709 |
add_row_num(db, in_pkeys_ref[0]) # for joining it with output pkeys |
709 | 710 |
|
Also available in: Unified diff
sql.py: put_table(): Changed temp_prefix to a suffix so main name won't be removed if name is truncated