Project

General

Profile

« Previous | Next » 

Revision 2279

sql.py: put_table(): Removed no longer used table_is_esc param

View differences:

lib/sql.py
734 734
        return put(db, table, row, pkey, row_ct_ref) # insert new row
735 735

  
736 736
def put_table(db, out_table, in_tables, mapping, limit=None, start=0,
737
    row_ct_ref=None, table_is_esc=False):
737
    row_ct_ref=None):
738 738
    '''Recovers from errors.
739 739
    Only works under PostgreSQL (uses INSERT RETURNING).
740 740
    @param in_tables The main input table to select from, followed by a list of
741 741
        tables to join with it using the main input table's pkey
742
    @return (table, col) Where the pkeys (from INSERT RETURNING) are made
742
    @return sql_gen.Col Where the pkeys (from INSERT RETURNING) are made
743 743
        available
744 744
    '''
745 745
    temp_prefix = clean_name(out_table)
......
748 748
    # Join together input tables
749 749
    in_tables = in_tables[:] # don't modify input!
750 750
    in_tables0 = in_tables.pop(0) # first table is separate
751
    in_pkey = pkey(db, in_tables0, recover=True, table_is_esc=table_is_esc)
752
    in_pkey_col = sql_gen.col2sql_gen(in_pkey, in_tables0, table_is_esc)
751
    in_pkey = pkey(db, in_tables0, recover=True)
752
    in_pkey_col = sql_gen.col2sql_gen(in_pkey, in_tables0)
753 753
    insert_joins = [in_tables0]+[sql_gen.Join(v, {in_pkey: sql_gen.join_using})
754 754
        for v in in_tables]
755 755
    
756
    out_pkey = pkey(db, out_table, recover=True, table_is_esc=table_is_esc)
757
    out_pkey_col = sql_gen.col2sql_gen(out_pkey, out_table, table_is_esc)
756
    out_pkey = pkey(db, out_table, recover=True)
757
    out_pkey_col = sql_gen.col2sql_gen(out_pkey, out_table)
758 758
    
759 759
    pkeys = [in_pkey, out_pkey]
760 760
    pkeys_cols = [in_pkey_col, out_pkey_col]
......
771 771
    distinct_on = []
772 772
    def mk_main_select(cols):
773 773
        return mk_select(db, insert_joins, cols, conds, distinct_on,
774
            order_by=None, limit=limit, start=start, table_is_esc=table_is_esc,
775
            default_table=in_tables0)
774
            order_by=None, limit=limit, start=start, default_table=in_tables0)
776 775
    
777 776
    def log_ignore(in_col, value):
778 777
        db.log_debug('Ignoring rows with '+in_col+' = '+value)
......
788 787
                select_joins = insert_joins+[sql_gen.Join(out_table, join_cols)]
789 788
                db.log_debug('Getting pkeys of already existing rows')
790 789
                run_query_into_pkeys(*mk_select(db, select_joins, pkeys_cols,
791
                    order_by=None, start=0, table_is_esc=table_is_esc))
790
                    order_by=None, start=0))
792 791
                
793 792
                # Prepare to insert new rows
794 793
                input_join_cols = join_cols.values()
......
801 800
            db.log_debug('Inserting new rows')
802 801
            cur = insert_select(db, out_table, mapping.keys(),
803 802
                *mk_main_select(mapping.values()), returning=out_pkey,
804
                into_ref=out_pkeys_ref, recover=True, table_is_esc=table_is_esc)
803
                into_ref=out_pkeys_ref, recover=True)
805 804
            if row_ct_ref != None and cur.rowcount >= 0:
806 805
                row_ct_ref[0] += cur.rowcount
807 806
                add_row_num(db, out_pkeys_ref[0]) # for joining with input pkeys
......
830 829
                db.log_debug('Missing mapping for '+out_col)
831 830
                run_query_into_pkeys(*mk_select(db, insert_joins,
832 831
                    [in_pkey_col, sql_gen.NamedCode(out_pkey, None)],
833
                    order_by=None, start=0, table_is_esc=table_is_esc))
832
                    order_by=None, start=0))
834 833
                break
835 834
            else:
836 835
                log_ignore(in_col, 'NULL')

Also available in: Unified diff