Revision 2207
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
786 | 786 |
run_query_into(db, query, params, into_ref=pkeys_ref) |
787 | 787 |
pkeys_table_exists_ref[0] = True |
788 | 788 |
|
789 |
def mk_select_(cols, distinct_on=None): |
|
789 |
distinct_on = None |
|
790 |
def mk_main_select(cols): |
|
790 | 791 |
return mk_select(db, insert_joins, cols, distinct_on=distinct_on, |
791 | 792 |
order_by=None, limit=limit, start=start, table_is_esc=table_is_esc) |
792 | 793 |
|
793 | 794 |
# Do inserts and selects |
794 | 795 |
out_pkeys_ref = ['out_pkeys_'+temp_suffix] |
795 |
distinct_on = None |
|
796 | 796 |
while True: |
797 | 797 |
try: |
798 | 798 |
cur = insert_select(db, out_table, mapping.keys(), |
799 |
*mk_select_(mapping.values(), distinct_on), returning=out_pkey,
|
|
799 |
*mk_main_select(mapping.values()), returning=out_pkey,
|
|
800 | 800 |
into_ref=out_pkeys_ref, recover=True, table_is_esc=table_is_esc) |
801 | 801 |
if row_ct_ref != None and cur.rowcount >= 0: |
802 | 802 |
row_ct_ref[0] += cur.rowcount |
... | ... | |
804 | 804 |
|
805 | 805 |
# Get input pkeys corresponding to rows in insert |
806 | 806 |
in_pkeys_ref = ['in_pkeys_'+temp_suffix] |
807 |
run_query_into(db, *mk_select_([in_pkey]), into_ref=in_pkeys_ref) |
|
807 |
run_query_into(db, *mk_main_select([in_pkey]), |
|
808 |
into_ref=in_pkeys_ref) |
|
808 | 809 |
add_row_num(db, in_pkeys_ref[0]) # for joining with output pkeys |
809 | 810 |
|
810 | 811 |
# Join together output and input pkeys |
Also available in: Unified diff
sql.py: put_table(): mk_select_(): Fixed bug where it was sometimes being called without distinct_on, causing it to return a different # of rows. Renamed mk_select_() to mk_main_select() for clarity.